Skip to content

Commit 3fcd99d

Browse files
authored
adds getters for diff algorithms (microsoft#185497)
1 parent 448ec31 commit 3fcd99d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/vs/editor/common/diff/linesDiffComputers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import { SmartLinesDiffComputer } from 'vs/editor/common/diff/smartLinesDiffComp
77
import { StandardLinesDiffComputer } from 'vs/editor/common/diff/standardLinesDiffComputer';
88

99
export const linesDiffComputers = {
10-
legacy: new SmartLinesDiffComputer(),
11-
advanced: new StandardLinesDiffComputer(),
10+
getLegacy: () => new SmartLinesDiffComputer(),
11+
getAdvanced: () => new StandardLinesDiffComputer(),
1212
};

src/vs/editor/common/services/editorSimpleWorker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
413413
}
414414

415415
private static computeDiff(originalTextModel: ICommonModel | ITextModel, modifiedTextModel: ICommonModel | ITextModel, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): IDiffComputationResult {
416-
const diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.advanced : linesDiffComputers.legacy;
416+
const diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.getAdvanced() : linesDiffComputers.getLegacy();
417417

418418
const originalLines = originalTextModel.getLinesContent();
419419
const modifiedLines = modifiedTextModel.getLinesContent();
@@ -609,7 +609,7 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
609609
const originalLines = original.split(/\r\n|\n|\r/);
610610
const modifiedLines = text.split(/\r\n|\n|\r/);
611611

612-
const diff = linesDiffComputers.advanced.computeDiff(originalLines, modifiedLines, options);
612+
const diff = linesDiffComputers.getAdvanced().computeDiff(originalLines, modifiedLines, options);
613613

614614
const start = Range.lift(range).getStartPosition();
615615

src/vs/workbench/contrib/mergeEditor/test/browser/model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class MergeModelInterface extends Disposable {
283283

284284
const diffComputer: IMergeDiffComputer = {
285285
async computeDiff(textModel1: ITextModel, textModel2: ITextModel, reader: IReader): Promise<IMergeDiffComputerResult> {
286-
const result = await linesDiffComputers.legacy.computeDiff(
286+
const result = await linesDiffComputers.getLegacy().computeDiff(
287287
textModel1.getLinesContent(),
288288
textModel2.getLinesContent(),
289289
{ ignoreTrimWhitespace: false, maxComputationTimeMs: 10000, computeMoves: false }

0 commit comments

Comments
 (0)