-
Notifications
You must be signed in to change notification settings - Fork 7k
fix(win32): Normalise LSP paths on windows (fixes lua) #5597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,21 @@ | ||
| import { realpathSync } from "fs" | ||
| import { exists } from "fs/promises" | ||
| import { dirname, join, relative } from "path" | ||
|
|
||
| export namespace Filesystem { | ||
| /** | ||
| * On Windows, normalize a path to its canonical casing using the filesystem. | ||
| * This is needed because Windows paths are case-insensitive but LSP servers | ||
| * may return paths with different casing than what we send them. | ||
| */ | ||
| export function normalizePath(p: string): string { | ||
| if (process.platform !== "win32") return p | ||
| try { | ||
| return realpathSync.native(p) | ||
| } catch { | ||
| return p | ||
| } | ||
| } | ||
|
Comment on lines
+11
to
+18
|
||
| export function overlaps(a: string, b: string) { | ||
| const relA = relative(a, b) | ||
| const relB = relative(b, a) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normalizePath function silently returns the original path when an error occurs. This could hide important issues like permission errors or invalid paths. Consider logging the error for debugging purposes, or at least distinguishing between "path doesn't exist" (which is acceptable) and other errors that might indicate a real problem. This is especially important for a Windows-specific fix where understanding why normalization failed could be crucial for troubleshooting.