Skip to content

Commit cfac77e

Browse files
authored
Sync whitespace options even when detectIndentation is on (#7965)
2 parents a09b1f9 + 69e52b9 commit cfac77e

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/lsptoolshost/universalEditorConfigProvider.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export function readEquivalentVsCodeConfiguration(serverSideOptionName: string):
2929
}
3030

3131
function readTabSize(configuration: WorkspaceConfiguration): string {
32-
return readValueIfDetectIndentationIsOff(configuration, 'editor.tabSize', '4');
32+
return readVsCodeConfigurations<string>(configuration, 'editor.tabSize');
3333
}
3434

3535
function readIndentSize(configuration: WorkspaceConfiguration): string {
36-
const indentSize = readValueIfDetectIndentationIsOff<string>(configuration, 'editor.indentSize', '4');
36+
const indentSize = readVsCodeConfigurations<string>(configuration, 'editor.indentSize');
3737
// indent size could be a number or 'tabSize'. If it is 'tabSize', read the 'tabSize' section from config.
3838
if (indentSize == 'tabSize') {
3939
return readTabSize(configuration);
@@ -43,7 +43,7 @@ function readIndentSize(configuration: WorkspaceConfiguration): string {
4343
}
4444

4545
function readInsertSpaces(configuration: WorkspaceConfiguration): string {
46-
const insertSpace = readValueIfDetectIndentationIsOff<boolean>(configuration, 'editor.insertSpaces', true);
46+
const insertSpace = readVsCodeConfigurations<boolean>(configuration, 'editor.insertSpaces');
4747
return insertSpace ? 'space' : 'tab';
4848
}
4949

@@ -62,21 +62,6 @@ function readInsertFinalNewline(configuration: WorkspaceConfiguration): string {
6262
return readVsCodeConfigurations<string>(configuration, 'files.insertFinalNewline');
6363
}
6464

65-
function readValueIfDetectIndentationIsOff<T>(
66-
configuration: WorkspaceConfiguration,
67-
vscodeConfigName: string,
68-
defaultValue: T
69-
): T {
70-
// If detectIndentation is on, tabSize, indentSize and insertSpaces would be overridden by vscode based on the file's content.
71-
// The values in settings become meaningless, so ask the server to fall back to default value.
72-
// TODO: Both 'editor.detectIndentation' and.editorconfig provided the same functions here, we need to find a graceful way to handle them.
73-
if (configuration.get<boolean>('editor.detectIndentation')) {
74-
return defaultValue;
75-
}
76-
77-
return readVsCodeConfigurations(configuration, vscodeConfigName);
78-
}
79-
8065
function readVsCodeConfigurations<T>(configuration: WorkspaceConfiguration, vscodeConfigName: string): T {
8166
const configValue = configuration.get<T>(vscodeConfigName);
8267
if (configValue === undefined) {

0 commit comments

Comments
 (0)