Skip to content

Commit 0a64b77

Browse files
authored
Fix an issue with editorconfig tab_size (#13216)
1 parent c3f8d0c commit 0a64b77

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,16 +2914,22 @@ export class DefaultClient implements Client {
29142914
const settings: CppSettings = new CppSettings(this.RootUri);
29152915
if (settings.useVcFormat(editor.document)) {
29162916
const editorConfigSettings: any = getEditorConfigSettings(editor.document.uri.fsPath);
2917-
if (editorConfigSettings.indent_style === "space" || editorConfigSettings.indent_style === "tab") {
2918-
editor.options.insertSpaces = editorConfigSettings.indent_style === "space";
2917+
if (editorConfigSettings.indent_style === "tab") {
2918+
editor.options.insertSpaces = false;
2919+
} else if (editorConfigSettings.indent_style === "space") {
2920+
editor.options.insertSpaces = true;
2921+
}
2922+
if (editorConfigSettings.indent_size !== undefined) {
29192923
if (editorConfigSettings.indent_size === "tab") {
2920-
if (!editorConfigSettings.tab_width !== undefined) {
2921-
editor.options.tabSize = editorConfigSettings.tab_width;
2922-
}
2923-
} else if (editorConfigSettings.indent_size !== undefined) {
2924+
editor.options.indentSize = "tabSize";
2925+
} else {
2926+
editor.options.indentSize = editorConfigSettings.indent_size;
29242927
editor.options.tabSize = editorConfigSettings.indent_size;
29252928
}
29262929
}
2930+
if (editorConfigSettings.tab_width !== undefined) {
2931+
editor.options.tabSize = editorConfigSettings.tab_width;
2932+
}
29272933
if (editorConfigSettings.end_of_line !== undefined) {
29282934
void editor.edit((edit) => {
29292935
edit.setEndOfLine(editorConfigSettings.end_of_line === "lf" ? vscode.EndOfLine.LF : vscode.EndOfLine.CRLF);

0 commit comments

Comments
 (0)