fix(win32): Normalise LSP paths on windows (fixes lua) (#5597)

This commit is contained in:
Luke Parker
2025-12-16 10:01:03 +10:00
committed by GitHub
parent 89a4f1c1ae
commit 27e826eba6
5 changed files with 44 additions and 22 deletions

View File

@@ -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
}
}
export function overlaps(a: string, b: string) {
const relA = relative(a, b)
const relB = relative(b, a)