Skip to content

Commit 71a3d0a

Browse files
committed
use server side format code options matching arguments is omitted
1 parent 6374a3f commit 71a3d0a

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/server/protocol.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ declare namespace ts.server.protocol {
111111
}
112112

113113
export interface IndentationRequestArgs extends FileLocationRequestArgs {
114-
options: EditorSettings;
114+
options?: EditorSettings;
115115
}
116116

117117
/**

‎src/server/session.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ namespace ts.server {
783783
private getIndentation(args: protocol.IndentationRequestArgs) {
784784
const { file, project } = this.getFileAndProject(args);
785785
const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file));
786-
const indentation = project.languageService.getIndentationAtPosition(file, position, args.options);
786+
const options = args.options || this.projectService.getFormatCodeOptions(file);
787+
const indentation = project.languageService.getIndentationAtPosition(file, position, options);
787788
return { position, indentation };
788789
}
789790

@@ -855,17 +856,20 @@ namespace ts.server {
855856

856857
private getFormattingEditsForRangeFull(args: protocol.FormatRequestArgs) {
857858
const { file, project } = this.getFileAndProject(args);
858-
return project.languageService.getFormattingEditsForRange(file, args.position, args.endPosition, args.options);
859+
const options = args.options || this.projectService.getFormatCodeOptions(file);
860+
return project.languageService.getFormattingEditsForRange(file, args.position, args.endPosition, options);
859861
}
860862

861863
private getFormattingEditsForDocumentFull(args: protocol.FormatRequestArgs) {
862864
const { file, project } = this.getFileAndProject(args);
863-
return project.languageService.getFormattingEditsForDocument(file, args.options);
865+
const options = args.options || this.projectService.getFormatCodeOptions(file);
866+
return project.languageService.getFormattingEditsForDocument(file, options);
864867
}
865868

866869
private getFormattingEditsAfterKeystrokeFull(args: protocol.FormatOnKeyRequestArgs) {
867870
const { file, project } = this.getFileAndProject(args);
868-
return project.languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, args.options);
871+
const options = args.options || this.projectService.getFormatCodeOptions(file);
872+
return project.languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, options);
869873
}
870874

871875
private getFormattingEditsAfterKeystroke(args: protocol.FormatOnKeyRequestArgs): protocol.CodeEdit[] {

0 commit comments

Comments
 (0)