Skip to content

Commit b25d08d

Browse files
committed
Workaround the drive letter casing issue on windows.
1 parent ea33181 commit b25d08d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/clangd-context.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,34 @@ export class ClangdContext implements vscode.Disposable {
100100
// Do not switch to output window when clangd returns output.
101101
revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never,
102102

103+
uriConverters: {
104+
code2Protocol: (uri: vscode.Uri): string => {
105+
if (process.platform === 'win32') {
106+
107+
if (uri.scheme === 'file') {
108+
// https://github.com/clangd/vscode-clangd/issues/726
109+
// Remove this workaround once clangd fixes the issue on their side: https://github.com/clangd/clangd/issues/108
110+
111+
// Fix lower case drive letters on Windows
112+
let fsPath = uri.fsPath
113+
114+
// Extract the drive letter (first two characters, e.g., "c:")
115+
const driveLetterMatch = fsPath.match(/^([a-z]):/i);
116+
117+
if (driveLetterMatch) {
118+
// Convert the drive letter to uppercase
119+
const driveLetter = driveLetterMatch[1].toUpperCase();
120+
// Replace the old drive letter with the new one
121+
return "file:///" + fsPath.replace(/^([a-z]):/i, `${driveLetter}:`);
122+
}
123+
124+
}
125+
}
126+
return uri.toString();
127+
},
128+
protocol2Code: (uri: string) => vscode.Uri.parse(uri),
129+
},
130+
103131
// We hack up the completion items a bit to prevent VSCode from re-ranking
104132
// and throwing away all our delicious signals like type information.
105133
//

0 commit comments

Comments
 (0)