Skip to content

Commit 3117776

Browse files
authored
json edit: Ignore removes in a non existing node (microsoft#210025)
1 parent 4c366ec commit 3117776

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vs/base/common/jsonEdit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function setProperty(text: string, originalPath: JSONPath, value: any, fo
3535
if (!parent) {
3636
// empty document
3737
if (value === undefined) { // delete
38-
throw new Error('Can not delete in empty document');
38+
return []; // property does not exist, nothing to do
3939
}
4040
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
4141
} else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {

0 commit comments

Comments
 (0)