本文整理汇总了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());
}