Skip to content

Commit 83f8f52

Browse files
committed
Improve debugging output
1 parent 4aa873b commit 83f8f52

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/vs/editor/common/model/editStack.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { URI } from 'vs/base/common/uri';
1313
import { TextChange, compressConsecutiveTextChanges } from 'vs/editor/common/model/textChange';
1414
import * as buffer from 'vs/base/common/buffer';
1515
import { IDisposable } from 'vs/base/common/lifecycle';
16+
import { basename } from 'vs/base/common/resources';
1617

1718
function uriGetComparisonKey(resource: URI): string {
1819
return resource.toString();
@@ -340,6 +341,14 @@ export class MultiModelEditStackElement implements IWorkspaceUndoRedoElement {
340341
public split(): IResourceUndoRedoElement[] {
341342
return this._editStackElementsArr;
342343
}
344+
345+
public toString(): string {
346+
let result: string[] = [];
347+
for (const editStackElement of this._editStackElementsArr) {
348+
result.push(`${basename(editStackElement.resource)}: ${editStackElement}`);
349+
}
350+
return `{${result.join(', ')}}`;
351+
}
343352
}
344353

345354
export type EditStackElement = SingleModelEditStackElement | MultiModelEditStackElement;

src/vs/editor/common/model/textChange.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
import * as buffer from 'vs/base/common/buffer';
77
import { decodeUTF16LE } from 'vs/editor/common/core/stringBuilder';
88

9+
function escapeNewLine(str: string): string {
10+
return (
11+
str
12+
.replace(/\n/g, '\\n')
13+
.replace(/\r/g, '\\r')
14+
);
15+
}
16+
917
export class TextChange {
1018

1119
public get oldLength(): number {
@@ -33,12 +41,12 @@ export class TextChange {
3341

3442
public toString(): string {
3543
if (this.oldText.length === 0) {
36-
return `(insert@${this.oldPosition} "${this.newText}")`;
44+
return `(insert@${this.oldPosition} "${escapeNewLine(this.newText)}")`;
3745
}
3846
if (this.newText.length === 0) {
39-
return `(delete@${this.oldPosition} "${this.oldText}")`;
47+
return `(delete@${this.oldPosition} "${escapeNewLine(this.oldText)}")`;
4048
}
41-
return `(replace@${this.oldPosition} "${this.oldText}" with "${this.newText}")`;
49+
return `(replace@${this.oldPosition} "${escapeNewLine(this.oldText)}" with "${escapeNewLine(this.newText)}")`;
4250
}
4351

4452
private static _writeStringSize(str: string): number {

src/vs/platform/undoRedo/common/undoRedoService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ResourceStackElement {
5151
}
5252

5353
public toString(): string {
54-
return `[${this.id}] [${this.isValid ? 'VALID' : 'INVALID'}] ${this.actual}`;
54+
return `[id:${this.id}] [group:${this.groupId}] [${this.isValid ? 'VALID' : 'INVALID'}] ${this.actual}`;
5555
}
5656
}
5757

@@ -172,7 +172,7 @@ class WorkspaceStackElement {
172172
}
173173

174174
public toString(): string {
175-
return `[${this.id}] [${this.invalidatedResources ? 'INVALID' : 'VALID'}] ${this.actual}`;
175+
return `[id:${this.id}] [group:${this.groupId}] [${this.invalidatedResources ? 'INVALID' : 'VALID'}] ${this.actual}`;
176176
}
177177
}
178178

0 commit comments

Comments
 (0)