diff --git a/src/impl/edit.ts b/src/impl/edit.ts index d524896..0f8c14b 100644 --- a/src/impl/edit.ts +++ b/src/impl/edit.ts @@ -12,7 +12,8 @@ export function removeProperty(text: string, path: JSONPath, formattingOptions: return setProperty(text, path, void 0, formattingOptions); } -export function setProperty(text: string, path: JSONPath, value: any, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] { +export function setProperty(text: string, originalPath: JSONPath, value: any, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] { + let path = originalPath.slice() let errors: ParseError[] = []; let root = parseTree(text, errors); let parent: Node | undefined = void 0; @@ -160,4 +161,4 @@ export function applyEdit(text: string, edit: Edit): string { export function isWS(text: string, offset: number) { return '\r\n \t'.indexOf(text.charAt(offset)) !== -1; -} \ No newline at end of file +}