Skip to content

Commit

Permalink
Workaround the drive letter casing issue on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
raldone01 committed Dec 5, 2024
1 parent ea33181 commit b25d08d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,34 @@ export class ClangdContext implements vscode.Disposable {
// Do not switch to output window when clangd returns output.
revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never,

uriConverters: {
code2Protocol: (uri: vscode.Uri): string => {
if (process.platform === 'win32') {

if (uri.scheme === 'file') {
// https://github.com/clangd/vscode-clangd/issues/726
// Remove this workaround once clangd fixes the issue on their side: https://github.com/clangd/clangd/issues/108

// Fix lower case drive letters on Windows
let fsPath = uri.fsPath

// Extract the drive letter (first two characters, e.g., "c:")
const driveLetterMatch = fsPath.match(/^([a-z]):/i);

if (driveLetterMatch) {
// Convert the drive letter to uppercase
const driveLetter = driveLetterMatch[1].toUpperCase();
// Replace the old drive letter with the new one
return "file:///" + fsPath.replace(/^([a-z]):/i, `${driveLetter}:`);
}

}
}
return uri.toString();
},
protocol2Code: (uri: string) => vscode.Uri.parse(uri),
},

// We hack up the completion items a bit to prevent VSCode from re-ranking
// and throwing away all our delicious signals like type information.
//
Expand Down

0 comments on commit b25d08d

Please sign in to comment.