mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-22 23:05:26 +01:00
Improve debugging output
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user