Skip to content

Commit

Permalink
Updated Description for Preferred Path Separator Setting and Refactor…
Browse files Browse the repository at this point in the history
… Its Usage (#13082)

* Updated description for preferred path separator setting.

* Change wording.

* Refactor configuration quickpick to correctly reflect preferred path separator.
  • Loading branch information
browntarik authored Dec 31, 2024
1 parent 2bff033 commit 42c6d99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
"c_cpp.configuration.exclusionPolicy.checkFolders.description": "The exclusion filters will only be evaluated once per folder (individual files are not checked).",
"c_cpp.configuration.exclusionPolicy.checkFilesAndFolders.description": "The exclusion filters will be evaluated against every file and folder encountered.",
"c_cpp.configuration.preferredPathSeparator.markdownDescription": {
"message": "The character used as a path separator for `#include` auto-completion results.",
"message": "The character used as a path separator for generated user paths.",
"comment": [
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
Expand Down
13 changes: 11 additions & 2 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,8 @@ export class DefaultClient implements Client {
private static readonly compileCommandsLabel: string = "compile_commands.json";
private static readonly compilersLabel: string = "compilers";

public async showSelectIntelliSenseConfiguration(paths: string[], compilersOnly?: boolean): Promise<number> {
public async showSelectIntelliSenseConfiguration(paths: string[], preferredPathSeparator: string, compilersOnly?: boolean): Promise<number> {
paths = paths.map(p => p.replace(/[\\/]/g, preferredPathSeparator));
const options: vscode.QuickPickOptions = {};
options.placeHolder = compilersOnly || !vscode.workspace.workspaceFolders || !this.RootFolder ?
localize("select.compiler", "Select a compiler to configure for IntelliSense") :
Expand Down Expand Up @@ -1077,7 +1078,13 @@ export class DefaultClient implements Client {
installShown = false;
}
paths.push(localize("noConfig.string", "Do not configure with a compiler (not recommended)"));
const index: number = await this.showSelectIntelliSenseConfiguration(paths, showCompilersOnly);
let preferredPathSeparator: string = settings.preferredPathSeparator;
if (preferredPathSeparator === "Forward Slash") {
preferredPathSeparator = "/";
} else if (preferredPathSeparator === "Backslash") {
preferredPathSeparator = "\\";
}
const index: number = await this.showSelectIntelliSenseConfiguration(paths, preferredPathSeparator, showCompilersOnly);
let action: string = "";
let configurationSelected: boolean = false;
const fromStatusBarButton: boolean = !showCompilersOnly;
Expand Down Expand Up @@ -1128,7 +1135,9 @@ export class DefaultClient implements Client {
} else {
action = "select compiler";
const newCompiler: string = util.isCl(paths[index]) ? "cl.exe" : paths[index];

settings.defaultCompilerPath = newCompiler;
settings.defaultCompilerPath = settings.defaultCompilerPath.replace(/[\\/]/g, preferredPathSeparator);
await this.configuration.updateCompilerPathIfSet(newCompiler);
void SessionState.trustedCompilerFound.set(true);
}
Expand Down

0 comments on commit 42c6d99

Please sign in to comment.