mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Fix #47228 - Don't autofix JSON incorrectly when the user has only typed a key and colon
This commit is contained in:
parent
5a2a746bd9
commit
93582ce6de
|
@ -70,7 +70,12 @@ function autoFixSettingsJSON(willSaveEvent: vscode.TextDocumentWillSaveEvent): v
|
|||
onError(error: ParseErrorCode, offset: number, length: number): void {
|
||||
if (error === ParseErrorCode.CommaExpected && lastEndOfSomething > -1) {
|
||||
const fixPosition = document.positionAt(lastEndOfSomething);
|
||||
edit.insert(document.uri, fixPosition, ',');
|
||||
|
||||
// Don't insert a comma immediately before a : or ' :'
|
||||
const colonRange = document.getWordRangeAtPosition(fixPosition, / *:/);
|
||||
if (!colonRange) {
|
||||
edit.insert(document.uri, fixPosition, ',');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue