Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/common/diff/diffChange.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
/**
7
* Represents information about a specific difference between two sequences.
8
*/
9
export class DiffChange {
10
11
/**
12
* The position of the first element in the original sequence which
13
* this change affects.
14
*/
15
public originalStart: number;
16
17
/**
18
* The number of elements from the original sequence which were
19
* affected.
20
*/
21
public originalLength: number;
22
23
/**
24
* The position of the first element in the modified sequence which
25
* this change affects.
26
*/
27
public modifiedStart: number;
28
29
/**
30
* The number of elements from the modified sequence which were
31
* affected (added).
32
*/
33
public modifiedLength: number;
34
35
/**
36
* Constructs a new DiffChange with the given sequence information
37
* and content.
38
*/
39
constructor(originalStart: number, originalLength: number, modifiedStart: number, modifiedLength: number) {
40
//Debug.Assert(originalLength > 0 || modifiedLength > 0, "originalLength and modifiedLength cannot both be <= 0");
41
this.originalStart = originalStart;
42
this.originalLength = originalLength;
43
this.modifiedStart = modifiedStart;
44
this.modifiedLength = modifiedLength;
45
}
46
47
/**
48
* The end point (exclusive) of the change in the original sequence.
49
*/
50
public getOriginalEnd() {
51
return this.originalStart + this.originalLength;
52
}
53
54
/**
55
* The end point (exclusive) of the change in the modified sequence.
56
*/
57
public getModifiedEnd() {
58
return this.modifiedStart + this.modifiedLength;
59
}
60
}
61
62