Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Description for Preferred Path Separator Setting and Refactor Its Usage #13082

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading