本文整理匯總了TypeScript中vs/editor/common/diff/diffComputer.DiffComputer類的典型用法代碼示例。如果您正苦於以下問題:TypeScript DiffComputer類的具體用法?TypeScript DiffComputer怎麽用?TypeScript DiffComputer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DiffComputer類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: computeDiff
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());
}
示例2: assertDiff
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);
}
示例3: computeDirtyDiff
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());
}