diff --git a/src/vs/base/common/jsonFormatter.ts b/src/vs/base/common/jsonFormatter.ts index 422ade29a0704ed0a98558a53eaec016d719624d..686ecd48b0c0efc35f91179b2910e8a21870849e 100644 --- a/src/vs/base/common/jsonFormatter.ts +++ b/src/vs/base/common/jsonFormatter.ts @@ -27,6 +27,17 @@ export interface Edit { content: string; } +export function applyEdit(text: string, edit: Edit) : string { + return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length); +} + +export function applyEdits(text: string, edits: Edit[]) : string { + for (let i = edits.length - 1; i >= 0; i--) { + text = applyEdit(text, edits[i]); + } + return text; +} + export function format(documentText: string, range: { offset: number, length: number}, options: FormattingOptions): Edit[] { let initialIndentLevel: number; let value: string;