Skip to content

Commit

Permalink
Fix an issue with editorconfig tab_size (#13216)
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms authored Jan 30, 2025
1 parent c3f8d0c commit 0a64b77
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2914,16 +2914,22 @@ export class DefaultClient implements Client {
const settings: CppSettings = new CppSettings(this.RootUri);
if (settings.useVcFormat(editor.document)) {
const editorConfigSettings: any = getEditorConfigSettings(editor.document.uri.fsPath);
if (editorConfigSettings.indent_style === "space" || editorConfigSettings.indent_style === "tab") {
editor.options.insertSpaces = editorConfigSettings.indent_style === "space";
if (editorConfigSettings.indent_style === "tab") {
editor.options.insertSpaces = false;
} else if (editorConfigSettings.indent_style === "space") {
editor.options.insertSpaces = true;
}
if (editorConfigSettings.indent_size !== undefined) {
if (editorConfigSettings.indent_size === "tab") {
if (!editorConfigSettings.tab_width !== undefined) {
editor.options.tabSize = editorConfigSettings.tab_width;
}
} else if (editorConfigSettings.indent_size !== undefined) {
editor.options.indentSize = "tabSize";
} else {
editor.options.indentSize = editorConfigSettings.indent_size;
editor.options.tabSize = editorConfigSettings.indent_size;
}
}
if (editorConfigSettings.tab_width !== undefined) {
editor.options.tabSize = editorConfigSettings.tab_width;
}
if (editorConfigSettings.end_of_line !== undefined) {
void editor.edit((edit) => {
edit.setEndOfLine(editorConfigSettings.end_of_line === "lf" ? vscode.EndOfLine.LF : vscode.EndOfLine.CRLF);
Expand Down

0 comments on commit 0a64b77

Please sign in to comment.