Skip to content

Commit

Permalink
Decouple indentSize and tabSize if needed
Browse files Browse the repository at this point in the history
if indentSize is set to "tabSize" in config, and we try to set tabSize,
we will inadvertantly set indentSize as well. so decouple them in this
case.

and remove the hack that was here for this problem.
  • Loading branch information
yshui committed Dec 1, 2023
1 parent 75045dd commit 2584ce4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import * as editorconfig from 'editorconfig'
import {
TextDocument,
TextEditorOptions,
Uri,
window,
workspace,
commands,
} from 'vscode'
import { TextDocument, TextEditorOptions, Uri, window, workspace } from 'vscode'

/**
* Resolves `TextEditorOptions` for a `TextDocument`, combining the editor's
Expand Down Expand Up @@ -58,7 +51,14 @@ export async function applyTextEditorOptions(
return
}

commands.executeCommand('editor.action.detectIndentation') // <--- HACK!!
const workspaceConfig = workspace.getConfiguration('editor', editor?.document)
if (
workspaceConfig.get<number | string>('indentSize') === 'tabSize' &&
typeof newOptions.indentSize === 'undefined' &&
typeof newOptions.tabSize === 'number'
) {
newOptions.indentSize = editor.options.indentSize
}
editor.options = newOptions

if (onSuccess) {
Expand Down

0 comments on commit 2584ce4

Please sign in to comment.