Skip to content

Commit 59b04de

Browse files
tilligTylerLeonhardt
authored andcommitted
#1019: Get format settings from document editor instead of global. (#2035)
1 parent 0b4e032 commit 59b04de

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/features/DocumentFormatter.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class PSDocumentFormattingEditProvider implements
246246
const requestParams: DocumentRangeFormattingParams = {
247247
textDocument: TextDocumentIdentifier.create(document.uri.toString()),
248248
range: rangeParam,
249-
options: this.getEditorSettings(),
249+
options: this.getEditorSettings(editor),
250250
};
251251

252252
const formattingStartTime = new Date().valueOf();
@@ -309,11 +309,12 @@ class PSDocumentFormattingEditProvider implements
309309
PSDocumentFormattingEditProvider.documentLocker.lock(document, unlockWhenDone);
310310
}
311311

312-
private getEditorSettings(): { insertSpaces: boolean, tabSize: number } {
313-
const editorConfiguration = vscode.workspace.getConfiguration("editor");
312+
private getEditorSettings(editor: TextEditor): { insertSpaces: boolean, tabSize: number } {
313+
// Writing the editor options allows string or strong types going in, but always
314+
// resolves to an appropriate value on read.
314315
return {
315-
insertSpaces: editorConfiguration.get<boolean>("insertSpaces"),
316-
tabSize: editorConfiguration.get<number>("tabSize"),
316+
insertSpaces: editor.options.insertSpaces as boolean,
317+
tabSize: editor.options.tabSize as number,
317318
};
318319
}
319320
}

0 commit comments

Comments
 (0)