提交 3afb8fa0 编写于 作者: M Martin Aeschlimann

jsonEdit: don't complain when deleting a non existing property

上级 46e4970f
......@@ -63,7 +63,7 @@ export function setProperty(text: string, path: JSONPath, value: any, formatting
}
} else {
if (value === void 0) { // delete
throw new Error(`Property ${lastSegment} does not exist.`);
return []; // property does not exist, nothing to do
}
let newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
let index = getInsertionIndex ? getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册