diff --git a/src/vs/editor/common/model/editStack.ts b/src/vs/editor/common/model/editStack.ts index 5316fce9e95..0928d7d0e9b 100644 --- a/src/vs/editor/common/model/editStack.ts +++ b/src/vs/editor/common/model/editStack.ts @@ -13,6 +13,7 @@ import { URI } from 'vs/base/common/uri'; import { TextChange, compressConsecutiveTextChanges } from 'vs/editor/common/model/textChange'; import * as buffer from 'vs/base/common/buffer'; import { IDisposable } from 'vs/base/common/lifecycle'; +import { basename } from 'vs/base/common/resources'; function uriGetComparisonKey(resource: URI): string { return resource.toString(); @@ -340,6 +341,14 @@ export class MultiModelEditStackElement implements IWorkspaceUndoRedoElement { public split(): IResourceUndoRedoElement[] { return this._editStackElementsArr; } + + public toString(): string { + let result: string[] = []; + for (const editStackElement of this._editStackElementsArr) { + result.push(`${basename(editStackElement.resource)}: ${editStackElement}`); + } + return `{${result.join(', ')}}`; + } } export type EditStackElement = SingleModelEditStackElement | MultiModelEditStackElement; diff --git a/src/vs/editor/common/model/textChange.ts b/src/vs/editor/common/model/textChange.ts index c441bf7abc9..a213f13b494 100644 --- a/src/vs/editor/common/model/textChange.ts +++ b/src/vs/editor/common/model/textChange.ts @@ -6,6 +6,14 @@ import * as buffer from 'vs/base/common/buffer'; import { decodeUTF16LE } from 'vs/editor/common/core/stringBuilder'; +function escapeNewLine(str: string): string { + return ( + str + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + ); +} + export class TextChange { public get oldLength(): number { @@ -33,12 +41,12 @@ export class TextChange { public toString(): string { if (this.oldText.length === 0) { - return `(insert@${this.oldPosition} "${this.newText}")`; + return `(insert@${this.oldPosition} "${escapeNewLine(this.newText)}")`; } if (this.newText.length === 0) { - return `(delete@${this.oldPosition} "${this.oldText}")`; + return `(delete@${this.oldPosition} "${escapeNewLine(this.oldText)}")`; } - return `(replace@${this.oldPosition} "${this.oldText}" with "${this.newText}")`; + return `(replace@${this.oldPosition} "${escapeNewLine(this.oldText)}" with "${escapeNewLine(this.newText)}")`; } private static _writeStringSize(str: string): number { diff --git a/src/vs/platform/undoRedo/common/undoRedoService.ts b/src/vs/platform/undoRedo/common/undoRedoService.ts index 472bd7e27b0..7dd305c6714 100644 --- a/src/vs/platform/undoRedo/common/undoRedoService.ts +++ b/src/vs/platform/undoRedo/common/undoRedoService.ts @@ -51,7 +51,7 @@ class ResourceStackElement { } public toString(): string { - return `[${this.id}] [${this.isValid ? 'VALID' : 'INVALID'}] ${this.actual}`; + return `[id:${this.id}] [group:${this.groupId}] [${this.isValid ? 'VALID' : 'INVALID'}] ${this.actual}`; } } @@ -172,7 +172,7 @@ class WorkspaceStackElement { } public toString(): string { - return `[${this.id}] [${this.invalidatedResources ? 'INVALID' : 'VALID'}] ${this.actual}`; + return `[id:${this.id}] [group:${this.groupId}] [${this.invalidatedResources ? 'INVALID' : 'VALID'}] ${this.actual}`; } }