Skip to content

fix(vscode): normalize paths on Windows#18627

Closed
dwelle wants to merge 1 commit intooxc-project:mainfrom
dwelle:fix/18514
Closed

fix(vscode): normalize paths on Windows#18627
dwelle wants to merge 1 commit intooxc-project:mainfrom
dwelle:fix/18514

Conversation

@dwelle
Copy link

@dwelle dwelle commented Jan 27, 2026

fix #18514

The fix was vibecoded by Claude Code

How I tested:

  1. $ cd editors/vscode
  2. $ pnpm run compile
  3. $ pnpm run package
  4. install the extension from the vsix
  5. check on test-utils.ts which was previously failing
Code_HdT82plwSF.mp4

@dwelle dwelle requested a review from camc314 as a code owner January 27, 2026 11:52
Copilot AI review requested due to automatic review settings January 27, 2026 11:52
@github-actions github-actions bot added A-editor Area - Editor and Language Server C-bug Category - Bug labels Jan 27, 2026
@dwelle dwelle changed the title fix(vscode): normalize paths for on windows fix(vscode): normalize paths on Windows Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Windows-specific bug where the VSCode extension fails to re-lint files on change/save due to inconsistent drive letter casing in file paths. The issue occurred because different parts of VSCode's API return workspace URIs with different casings (e.g., /c:/ vs /C:/), causing Map lookups to fail.

Changes:

  • Added normalizeWorkspacePath() method to consistently lowercase URI paths on Windows
  • Updated all Map operations (set, delete, get) to use normalized paths
  • Added comprehensive documentation explaining the Windows path casing issue

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +32
private normalizeWorkspacePath(uri: Uri): string {
const path = uri.path;
return process.platform === "win32" ? path.toLowerCase() : path;
}
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding unit tests for the normalizeWorkspacePath method to verify that it correctly handles different path casings on Windows. For example, test that paths like /C:/Users/Project and /c:/users/project both normalize to the same value on Windows, while paths on other platforms remain unchanged.

This would help prevent regressions and document the expected behavior, especially since the issue being fixed (path casing on Windows) is somewhat subtle.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we wanna test this, should we mock process.platform.win32 since the tests are only running on linux?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be needed when .fsPath is used 🤞

@Sysix Sysix self-assigned this Jan 27, 2026
@Sysix
Copy link
Member

Sysix commented Jan 29, 2026

Can you test your problem by avoiding toLowerCase() and use .fsPath instead of .path. From the docs:

		/**
		 * The string representing the corresponding file system path of this Uri.
		 *
		 * Will handle UNC paths and normalize windows drive letters to lower-case. Also
		 * uses the platform specific path separator.
		 *
		 * * Will *not* validate the path for invalid characters and semantics.
		 * * Will *not* look at the scheme of this Uri.
		 * * The resulting string shall *not* be used for display purposes but
		 * for disk operations, like `readFile` et al.
		 *
		 * The *difference* to the {@linkcode Uri.path path}-property is the use of the platform specific
		 * path separator and the handling of UNC paths. The sample below outlines the difference:
		 * ```ts
		 * const u = URI.parse('file://server/c$/folder/file.txt')
		 * u.authority === 'server'
		 * u.path === '/c$/folder/file.txt'
		 * u.fsPath === '\\server\c$\folder\file.txt'
		 * ```
		 */
		readonly fsPath: string;

@camc314 camc314 closed this Jan 31, 2026
graphite-app bot pushed a commit that referenced this pull request Jan 31, 2026
Boshen pushed a commit to oxc-project/oxc-vscode that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: vscode doesn't re-lint on change/save on Windows in unknown circumstances

4 participants