Skip to content

Commit 66f4dba

Browse files
Kapil Borledaviwil
Kapil Borle
authored andcommitted
Add method to get formatting options from configuration
1 parent 9112df3 commit 66f4dba

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/features/DocumentFormatter.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ class PSDocumentFormattingEditProvider implements
200200
DocumentFormattingRequest.type,
201201
{
202202
textDocument: TextDocumentIdentifier.create(document.uri.toString()),
203-
options: {
204-
insertSpaces: true,
205-
tabSize: 4
206-
}
203+
options: this.getEditorSettings()
207204
});
208205
}
209206

@@ -449,6 +446,14 @@ class PSDocumentFormattingEditProvider implements
449446
return settings;
450447
}
451448

449+
private getEditorSettings(): { insertSpaces: boolean, tabSize: number} {
450+
let editorConfiguration = vscode.workspace.getConfiguration("editor");
451+
return {
452+
insertSpaces: editorConfiguration.get<boolean>("insertSpaces"),
453+
tabSize: editorConfiguration.get<number>("tabSize")
454+
};
455+
}
456+
452457
private static showStatusBar(document: TextDocument, hideWhenDone: Thenable<any>): void {
453458
let statusBar = AnimatedStatusBar.showAnimatedStatusBarMessage("Formatting PowerShell document", hideWhenDone);
454459
this.statusBarTracker[document.uri.toString()] = statusBar;

0 commit comments

Comments
 (0)