Skip to content

Commit a2df173

Browse files
Refactor configuration quickpick to correctly reflect preferred path separator.
1 parent f6d07d9 commit a2df173

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ export class DefaultClient implements Client {
984984
private static readonly compileCommandsLabel: string = "compile_commands.json";
985985
private static readonly compilersLabel: string = "compilers";
986986

987-
public async showSelectIntelliSenseConfiguration(paths: string[], compilersOnly?: boolean): Promise<number> {
987+
public async showSelectIntelliSenseConfiguration(paths: string[], preferredPathSeparator: string, compilersOnly?: boolean): Promise<number> {
988+
paths = paths.map(p => p.replace(/[\\/]/g, preferredPathSeparator));
988989
const options: vscode.QuickPickOptions = {};
989990
options.placeHolder = compilersOnly || !vscode.workspace.workspaceFolders || !this.RootFolder ?
990991
localize("select.compiler", "Select a compiler to configure for IntelliSense") :
@@ -1077,7 +1078,13 @@ export class DefaultClient implements Client {
10771078
installShown = false;
10781079
}
10791080
paths.push(localize("noConfig.string", "Do not configure with a compiler (not recommended)"));
1080-
const index: number = await this.showSelectIntelliSenseConfiguration(paths, showCompilersOnly);
1081+
let preferredPathSeparator: string = settings.preferredPathSeparator;
1082+
if (preferredPathSeparator === "Forward Slash") {
1083+
preferredPathSeparator = "/";
1084+
} else if (preferredPathSeparator === "Backslash") {
1085+
preferredPathSeparator = "\\";
1086+
}
1087+
const index: number = await this.showSelectIntelliSenseConfiguration(paths, preferredPathSeparator, showCompilersOnly);
10811088
let action: string = "";
10821089
let configurationSelected: boolean = false;
10831090
const fromStatusBarButton: boolean = !showCompilersOnly;
@@ -1128,7 +1135,9 @@ export class DefaultClient implements Client {
11281135
} else {
11291136
action = "select compiler";
11301137
const newCompiler: string = util.isCl(paths[index]) ? "cl.exe" : paths[index];
1138+
11311139
settings.defaultCompilerPath = newCompiler;
1140+
settings.defaultCompilerPath = settings.defaultCompilerPath.replace(/[\\/]/g, preferredPathSeparator);
11321141
await this.configuration.updateCompilerPathIfSet(newCompiler);
11331142
void SessionState.trustedCompilerFound.set(true);
11341143
}

0 commit comments

Comments
 (0)