Skip to content

#1019: Get format settings from document editor instead of global. #2035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/features/DocumentFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class PSDocumentFormattingEditProvider implements
const requestParams: DocumentRangeFormattingParams = {
textDocument: TextDocumentIdentifier.create(document.uri.toString()),
range: rangeParam,
options: this.getEditorSettings(),
options: this.getEditorSettings(editor),
};

const formattingStartTime = new Date().valueOf();
Expand Down Expand Up @@ -309,11 +309,12 @@ class PSDocumentFormattingEditProvider implements
PSDocumentFormattingEditProvider.documentLocker.lock(document, unlockWhenDone);
}

private getEditorSettings(): { insertSpaces: boolean, tabSize: number } {
const editorConfiguration = vscode.workspace.getConfiguration("editor");
private getEditorSettings(editor: TextEditor): { insertSpaces: boolean, tabSize: number } {
// Writing the editor options allows string or strong types going in, but always
// resolves to an appropriate value on read.
return {
insertSpaces: editorConfiguration.get<boolean>("insertSpaces"),
tabSize: editorConfiguration.get<number>("tabSize"),
insertSpaces: editor.options.insertSpaces as boolean,
tabSize: editor.options.tabSize as number,
};
}
}
Expand Down