Skip to content

Commit fccf79d

Browse files
authored
feat: allow format range to be undefined (#272)
1 parent 82a2d01 commit fccf79d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/jsonLanguageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface LanguageService {
5353
getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
5454
findDefinition(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<DefinitionLink[]>;
5555
findLinks(document: TextDocument, doc: JSONDocument): PromiseLike<DocumentLink[]>;
56-
format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
56+
format(document: TextDocument, range: Range | undefined, options: FormattingOptions): TextEdit[];
5757
sort(document: TextDocument, options: SortOptions): TextEdit[];
5858
}
5959

@@ -92,7 +92,7 @@ export function getLanguageService(params: LanguageServiceParams): LanguageServi
9292
getSelectionRanges,
9393
findDefinition: () => Promise.resolve([]),
9494
findLinks,
95-
format: (document: TextDocument, range: Range, options: FormattingOptions) => format(document, options, range),
95+
format: (document: TextDocument, range: Range | undefined, options: FormattingOptions) => format(document, options, range),
9696
sort: (document: TextDocument, options: FormattingOptions) => sort(document, options)
9797
};
9898
}

src/test/formatter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ suite('JSON Formatter', () => {
2828
}
2929

3030
const document = TextDocument.create(uri, 'json', 0, unformatted);
31-
const edits = ls.format(document, range!, { tabSize: 2, insertSpaces: insertSpaces });
31+
const edits = ls.format(document, range, { tabSize: 2, insertSpaces: insertSpaces });
3232
const formatted = applyEdits(document, edits);
3333
assert.equal(formatted, expected);
3434
}

0 commit comments

Comments
 (0)