Skip to content

Fix path completion appending instead of replacing existing path - #38

Closed
chdsbd wants to merge 1 commit into
masterfrom
fix-path-completion-replace
Closed

chdsbd wants to merge 1 commit into
masterfrom
fix-path-completion-replace

Conversation

@chdsbd

@chdsbd chdsbd commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Problem

Picking a path completion while editing an existing path in CODEOWNERS added text after what was there instead of replacing it. There were two causes:

  1. parseAbsolutePatternFromLine read the whole path on the line and ignored the cursor position. With /src/comp|onents/Button.tsx (| is the cursor) it tried to list /src/components/Button.tsx as a folder and returned nothing. With /src/comp|onents it listed the contents of components/, one level too deep.
  2. Completion items had no range, so VS Code used its default word range, which splits on /, . and -. Picking file.test.ts with the cursor inside my-fi|le.test.ts replaced only part of the name and left the rest behind.

Changes

  • New parsePathSegmentAtCursor uses only the text before the cursor. The folder to list is everything up to the last /. The part being completed runs from there to the next /, whitespace, # or end of line, and every item's range covers that whole part, so selecting one replaces it.
  • Picking a folder inserts name/ and opens the next list of suggestions. It skips the / if one already follows.
  • git check-ignore now runs through execFile with a list of arguments instead of a shell string. File names with spaces or shell characters no longer break the command or get run by the shell.
  • Empty lines from git check-ignore output are no longer added to the ignored set.
  • Uses the async fs.promises.readdir instead of readdirSync, and drops the extra lodash sort because sortText already sets the order.
  • No completions when the cursor is outside the path, for example in the owners list or a comment.

Testing

  • Added test/suite/path-completion-item-provider.test.ts with unit tests for parsePathSegmentAtCursor.
  • npm test under xvfb: 12 passing.
  • npm run typecheck and eslint are clean.

Generated by Claude Code

Completions now use the text up to the cursor to find the directory to
list, and replace the whole path segment under the cursor rather than
VS Code's default word range. Also pass filenames to git check-ignore
as arguments instead of via a shell, and continue completing into
directories after selecting one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WKPZdizxX2RkqTQYLj6HcK

chdsbd commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

test (macos-latest) failed before any test ran, so the failure isn't caused by this PR's code. test (windows-latest) was cancelled when macOS failed. test (ubuntu-latest), including the new tests, and lint, typecheck, format and build all passed.

Downloading VS Code 1.144.0 ... darwin-arm64
Test error: Error: spawn .../.vscode-test/vscode-darwin-arm64-1.144.0/Visual Studio Code.app/Contents/MacOS/Electron ENOENT

Cause: Starting with VS Code 1.110, the macOS app bundle names its executable Code instead of Electron. The @vscode/test-electron@2.3.9 in our lockfile still launches Contents/MacOS/Electron. master last passed in May, when CI downloaded an older VS Code, and it would fail the same way now.

Fix: None exists yet. @vscode/test-electron handles the new name only in 3.1.0, and that version requires Node ≥22, while this repo is pinned to Node 18.14.2 in package.json (volta.node, which CI reads through node-version-file). The fix is to upgrade both:

-    "@vscode/test-electron": "^2.3.9",
+    "@vscode/test-electron": "^3.1.0",
...
   "volta": {
-    "node": "18.14.2"
+    "node": "22.x.y"
   }

and regenerate package-lock.json. Upgrading Node changes the whole toolchain, so I haven't put it in this PR. I'm re-running the failed jobs once so the Windows job gets a real result.


Generated by Claude Code

@chdsbd chdsbd closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants