Skip to content

Commit

Permalink
json edit: Ignore removes in a non existing node (#210025)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored Apr 10, 2024
1 parent 4c366ec commit 3117776
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/vs/base/common/jsonEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function setProperty(text: string, originalPath: JSONPath, value: any, fo
if (!parent) {
// empty document
if (value === undefined) { // delete
throw new Error('Can not delete in empty document');
return []; // property does not exist, nothing to do
}
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
} else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
Expand Down

0 comments on commit 3117776

Please sign in to comment.