Example #1
0
export function computeDiff(oneDocument: vscode.TextDocument, otherDocument: vscode.TextDocument): Thenable<vscode.LineChange[]> {
	const oneLines = getTextDocumentLines(oneDocument);
	const otherLines = getTextDocumentLines(otherDocument);
	const computer = new DiffComputer(oneLines, otherLines, {
		shouldPostProcessCharChanges: false,
		shouldIgnoreTrimWhitespace: false, // options?
		shouldConsiderTrimWhitespaceInEmptyCase: false
	});

	return toThenable(computer.computeDiff());
}
Example #2
0
function assertDiff(originalLines: string[], modifiedLines: string[], expectedChanges: IChange[], shouldPostProcessCharChanges: boolean = false, shouldIgnoreTrimWhitespace: boolean = false) {
	var diffComputer = new DiffComputer(originalLines, modifiedLines, {
		shouldPostProcessCharChanges: shouldPostProcessCharChanges || false,
		shouldIgnoreTrimWhitespace: shouldIgnoreTrimWhitespace || false,
		shouldConsiderTrimWhitespaceInEmptyCase: true
	});
	var changes = diffComputer.computeDiff();

	var extracted = [];
	for (var i = 0; i < changes.length; i++) {
		extracted.push(extractLineChangeRepresentation(changes[i], i < expectedChanges.length ? expectedChanges[i] : null));
	}
	assert.deepEqual(extracted, expectedChanges);
}
Example #3
0
	public computeDirtyDiff(originalUrl:string, modifiedUrl:string, ignoreTrimWhitespace:boolean):TPromise<EditorCommon.IChange[]> {
		let original = this._models[originalUrl];
		let modified = this._models[modifiedUrl];
		if (!original || !modified) {
			return null;
		}

		let originalLines = original.getLinesContent();
		let modifiedLines = modified.getLinesContent();
		let diffComputer = new DiffComputer(originalLines, modifiedLines, {
			shouldPostProcessCharChanges: false,
			shouldIgnoreTrimWhitespace: ignoreTrimWhitespace,
			shouldConsiderTrimWhitespaceInEmptyCase: false
		});
		return TPromise.as(diffComputer.computeDiff());
	}