Path: blob/main/src/vs/editor/common/diff/documentDiffProvider.ts
3294 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { CancellationToken } from '../../../base/common/cancellation.js';6import { Event } from '../../../base/common/event.js';7import { MovedText } from './linesDiffComputer.js';8import { DetailedLineRangeMapping } from './rangeMapping.js';9import { ITextModel } from '../model.js';1011/**12* A document diff provider computes the diff between two text models.13* @internal14*/15export interface IDocumentDiffProvider {16/**17* Computes the diff between the text models `original` and `modified`.18*/19computeDiff(original: ITextModel, modified: ITextModel, options: IDocumentDiffProviderOptions, cancellationToken: CancellationToken): Promise<IDocumentDiff>;2021/**22* Is fired when settings of the diff algorithm change that could alter the result of the diffing computation.23* Any user of this provider should recompute the diff when this event is fired.24*/25onDidChange: Event<void>;26}2728/**29* Options for the diff computation.30* @internal31*/32export interface IDocumentDiffProviderOptions {33/**34* When set to true, the diff should ignore whitespace changes.35*/36ignoreTrimWhitespace: boolean;3738/**39* A diff computation should throw if it takes longer than this value.40*/41maxComputationTimeMs: number;4243/**44* If set, the diff computation should compute moves in addition to insertions and deletions.45*/46computeMoves: boolean;4748extendToSubwords?: boolean;49}5051/**52* Represents a diff between two text models.53* @internal54*/55export interface IDocumentDiff {56/**57* If true, both text models are identical (byte-wise).58*/59readonly identical: boolean;6061/**62* If true, the diff computation timed out and the diff might not be accurate.63*/64readonly quitEarly: boolean;6566/**67* Maps all modified line ranges in the original to the corresponding line ranges in the modified text model.68*/69readonly changes: readonly DetailedLineRangeMapping[];7071/**72* Sorted by original line ranges.73* The original line ranges and the modified line ranges must be disjoint (but can be touching).74*/75readonly moves: readonly MovedText[];76}777879export const nullDocumentDiff: IDocumentDiff = Object.freeze({80identical: true,81quitEarly: false,82changes: Object.freeze([]),83moves: Object.freeze([])84});858687