@theia/scm 1.45.1 → 1.46.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/lib/browser/decorations/scm-decorations-service.d.ts +14 -14
- package/lib/browser/decorations/scm-decorations-service.js +101 -101
- package/lib/browser/decorations/scm-navigator-decorator.d.ts +25 -25
- package/lib/browser/decorations/scm-navigator-decorator.js +132 -132
- package/lib/browser/decorations/scm-tab-bar-decorator.d.ts +17 -17
- package/lib/browser/decorations/scm-tab-bar-decorator.js +93 -93
- package/lib/browser/dirty-diff/content-lines.d.ts +12 -12
- package/lib/browser/dirty-diff/content-lines.js +106 -106
- package/lib/browser/dirty-diff/content-lines.spec.d.ts +1 -1
- package/lib/browser/dirty-diff/content-lines.spec.js +39 -39
- package/lib/browser/dirty-diff/diff-computer.d.ts +29 -29
- package/lib/browser/dirty-diff/diff-computer.js +102 -102
- package/lib/browser/dirty-diff/diff-computer.spec.d.ts +1 -1
- package/lib/browser/dirty-diff/diff-computer.spec.js +315 -315
- package/lib/browser/dirty-diff/dirty-diff-decorator.d.ts +14 -14
- package/lib/browser/dirty-diff/dirty-diff-decorator.js +98 -98
- package/lib/browser/dirty-diff/dirty-diff-module.d.ts +3 -3
- package/lib/browser/dirty-diff/dirty-diff-module.js +24 -24
- package/lib/browser/scm-amend-component.d.ts +123 -123
- package/lib/browser/scm-amend-component.js +463 -463
- package/lib/browser/scm-amend-widget.d.ts +20 -20
- package/lib/browser/scm-amend-widget.js +101 -101
- package/lib/browser/scm-avatar-service.d.ts +3 -3
- package/lib/browser/scm-avatar-service.js +36 -36
- package/lib/browser/scm-commit-widget.d.ts +52 -52
- package/lib/browser/scm-commit-widget.js +199 -199
- package/lib/browser/scm-context-key-service.d.ts +10 -10
- package/lib/browser/scm-context-key-service.js +58 -58
- package/lib/browser/scm-contribution.d.ts +83 -83
- package/lib/browser/scm-contribution.js +356 -356
- package/lib/browser/scm-frontend-module.d.ts +6 -6
- package/lib/browser/scm-frontend-module.js +130 -130
- package/lib/browser/scm-groups-tree-model.d.ts +14 -14
- package/lib/browser/scm-groups-tree-model.js +97 -97
- package/lib/browser/scm-input.d.ts +53 -53
- package/lib/browser/scm-input.js +127 -127
- package/lib/browser/scm-layout-migrations.d.ts +9 -9
- package/lib/browser/scm-layout-migrations.js +79 -79
- package/lib/browser/scm-no-repository-widget.d.ts +8 -8
- package/lib/browser/scm-no-repository-widget.js +49 -49
- package/lib/browser/scm-preferences.d.ts +11 -11
- package/lib/browser/scm-preferences.js +51 -51
- package/lib/browser/scm-provider.d.ts +58 -58
- package/lib/browser/scm-provider.js +19 -19
- package/lib/browser/scm-quick-open-service.d.ts +11 -11
- package/lib/browser/scm-quick-open-service.js +73 -73
- package/lib/browser/scm-repository.d.ts +17 -17
- package/lib/browser/scm-repository.js +41 -41
- package/lib/browser/scm-service.d.ts +26 -26
- package/lib/browser/scm-service.js +108 -108
- package/lib/browser/scm-tree-label-provider.d.ts +7 -7
- package/lib/browser/scm-tree-label-provider.js +57 -57
- package/lib/browser/scm-tree-model.d.ts +74 -74
- package/lib/browser/scm-tree-model.js +351 -351
- package/lib/browser/scm-tree-widget.d.ts +208 -208
- package/lib/browser/scm-tree-widget.js +703 -703
- package/lib/browser/scm-widget.d.ts +40 -40
- package/lib/browser/scm-widget.js +218 -218
- package/package.json +6 -6
- package/src/browser/decorations/scm-decorations-service.ts +78 -78
- package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
- package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
- package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
- package/src/browser/dirty-diff/content-lines.ts +112 -112
- package/src/browser/dirty-diff/diff-computer.spec.ts +387 -387
- package/src/browser/dirty-diff/diff-computer.ts +129 -129
- package/src/browser/dirty-diff/dirty-diff-decorator.ts +107 -107
- package/src/browser/dirty-diff/dirty-diff-module.ts +24 -24
- package/src/browser/scm-amend-component.tsx +600 -600
- package/src/browser/scm-amend-widget.tsx +77 -77
- package/src/browser/scm-avatar-service.ts +27 -27
- package/src/browser/scm-commit-widget.tsx +215 -215
- package/src/browser/scm-context-key-service.ts +46 -46
- package/src/browser/scm-contribution.ts +361 -361
- package/src/browser/scm-frontend-module.ts +149 -149
- package/src/browser/scm-groups-tree-model.ts +78 -78
- package/src/browser/scm-input.ts +164 -164
- package/src/browser/scm-layout-migrations.ts +64 -64
- package/src/browser/scm-no-repository-widget.tsx +41 -41
- package/src/browser/scm-preferences.ts +63 -63
- package/src/browser/scm-provider.ts +91 -91
- package/src/browser/scm-quick-open-service.ts +48 -48
- package/src/browser/scm-repository.ts +52 -52
- package/src/browser/scm-service.ts +108 -108
- package/src/browser/scm-tree-label-provider.ts +44 -44
- package/src/browser/scm-tree-model.ts +405 -405
- package/src/browser/scm-tree-widget.tsx +838 -838
- package/src/browser/scm-widget.tsx +204 -204
- package/src/browser/style/dirty-diff-decorator.css +52 -52
- package/src/browser/style/dirty-diff.css +50 -50
- package/src/browser/style/index.css +271 -271
- package/src/browser/style/scm-amend-component.css +94 -94
- package/src/browser/style/scm.svg +4 -4
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as jsdiff from 'diff';
|
|
18
|
-
import { ContentLinesArrayLike } from './content-lines';
|
|
19
|
-
|
|
20
|
-
export class DiffComputer {
|
|
21
|
-
|
|
22
|
-
computeDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DiffResult[] {
|
|
23
|
-
const diffResult = diffArrays(previous, current);
|
|
24
|
-
return diffResult;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
computeDirtyDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DirtyDiff {
|
|
28
|
-
const added: LineRange[] = [];
|
|
29
|
-
const removed: number[] = [];
|
|
30
|
-
const modified: LineRange[] = [];
|
|
31
|
-
const changes = this.computeDiff(previous, current);
|
|
32
|
-
let lastLine = -1;
|
|
33
|
-
for (let i = 0; i < changes.length; i++) {
|
|
34
|
-
const change = changes[i];
|
|
35
|
-
const next = changes[i + 1];
|
|
36
|
-
if (change.added) {
|
|
37
|
-
// case: addition
|
|
38
|
-
const start = lastLine + 1;
|
|
39
|
-
const end = lastLine + change.count!;
|
|
40
|
-
added.push(<LineRange>{ start, end });
|
|
41
|
-
lastLine = end;
|
|
42
|
-
} else if (change.removed && next && next.added) {
|
|
43
|
-
const isFirstChange = i === 0;
|
|
44
|
-
const isLastChange = i === changes.length - 2;
|
|
45
|
-
const isNextEmptyLine = next.value.length > 0 && current[next.value[0]].length === 0;
|
|
46
|
-
const isPrevEmptyLine = change.value.length > 0 && previous[change.value[0]].length === 0;
|
|
47
|
-
|
|
48
|
-
if (isFirstChange && isNextEmptyLine) {
|
|
49
|
-
// special case: removing at the beginning
|
|
50
|
-
removed.push(0);
|
|
51
|
-
} else if (isFirstChange && isPrevEmptyLine) {
|
|
52
|
-
// special case: adding at the beginning
|
|
53
|
-
const start = 0;
|
|
54
|
-
const end = next.count! - 1;
|
|
55
|
-
added.push(<LineRange>{ start, end });
|
|
56
|
-
lastLine = end;
|
|
57
|
-
} else if (isLastChange && isNextEmptyLine) {
|
|
58
|
-
removed.push(lastLine + 1 /* = empty line */);
|
|
59
|
-
} else {
|
|
60
|
-
// default case is a modification
|
|
61
|
-
const start = lastLine + 1;
|
|
62
|
-
const end = lastLine + next.count!;
|
|
63
|
-
modified.push(<LineRange>{ start, end });
|
|
64
|
-
lastLine = end;
|
|
65
|
-
}
|
|
66
|
-
i++; // consume next eagerly
|
|
67
|
-
} else if (change.removed && !(next && next.added)) {
|
|
68
|
-
removed.push(Math.max(0, lastLine));
|
|
69
|
-
} else {
|
|
70
|
-
lastLine += change.count!;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return <DirtyDiff>{ added, removed, modified };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
class ArrayDiff extends jsdiff.Diff {
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
-
override tokenize(value: any): any {
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
override join(value: any): any {
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
-
override removeEmpty(value: any): any {
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const arrayDiff = new ArrayDiff();
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Computes diff without copying data.
|
|
97
|
-
*/
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
function diffArrays(oldArr: ContentLinesArrayLike, newArr: ContentLinesArrayLike): DiffResult[] {
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
-
return arrayDiff.diff(oldArr as any, newArr as any) as any;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface DiffResult {
|
|
105
|
-
value: [number, number];
|
|
106
|
-
count?: number;
|
|
107
|
-
added?: boolean;
|
|
108
|
-
removed?: boolean;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface DirtyDiff {
|
|
112
|
-
/**
|
|
113
|
-
* Lines added by comparison to previous revision.
|
|
114
|
-
*/
|
|
115
|
-
readonly added: LineRange[];
|
|
116
|
-
/**
|
|
117
|
-
* Lines, after which lines were removed by comparison to previous revision.
|
|
118
|
-
*/
|
|
119
|
-
readonly removed: number[];
|
|
120
|
-
/**
|
|
121
|
-
* Lines modified by comparison to previous revision.
|
|
122
|
-
*/
|
|
123
|
-
readonly modified: LineRange[];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface LineRange {
|
|
127
|
-
start: number;
|
|
128
|
-
end: number;
|
|
129
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as jsdiff from 'diff';
|
|
18
|
+
import { ContentLinesArrayLike } from './content-lines';
|
|
19
|
+
|
|
20
|
+
export class DiffComputer {
|
|
21
|
+
|
|
22
|
+
computeDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DiffResult[] {
|
|
23
|
+
const diffResult = diffArrays(previous, current);
|
|
24
|
+
return diffResult;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
computeDirtyDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DirtyDiff {
|
|
28
|
+
const added: LineRange[] = [];
|
|
29
|
+
const removed: number[] = [];
|
|
30
|
+
const modified: LineRange[] = [];
|
|
31
|
+
const changes = this.computeDiff(previous, current);
|
|
32
|
+
let lastLine = -1;
|
|
33
|
+
for (let i = 0; i < changes.length; i++) {
|
|
34
|
+
const change = changes[i];
|
|
35
|
+
const next = changes[i + 1];
|
|
36
|
+
if (change.added) {
|
|
37
|
+
// case: addition
|
|
38
|
+
const start = lastLine + 1;
|
|
39
|
+
const end = lastLine + change.count!;
|
|
40
|
+
added.push(<LineRange>{ start, end });
|
|
41
|
+
lastLine = end;
|
|
42
|
+
} else if (change.removed && next && next.added) {
|
|
43
|
+
const isFirstChange = i === 0;
|
|
44
|
+
const isLastChange = i === changes.length - 2;
|
|
45
|
+
const isNextEmptyLine = next.value.length > 0 && current[next.value[0]].length === 0;
|
|
46
|
+
const isPrevEmptyLine = change.value.length > 0 && previous[change.value[0]].length === 0;
|
|
47
|
+
|
|
48
|
+
if (isFirstChange && isNextEmptyLine) {
|
|
49
|
+
// special case: removing at the beginning
|
|
50
|
+
removed.push(0);
|
|
51
|
+
} else if (isFirstChange && isPrevEmptyLine) {
|
|
52
|
+
// special case: adding at the beginning
|
|
53
|
+
const start = 0;
|
|
54
|
+
const end = next.count! - 1;
|
|
55
|
+
added.push(<LineRange>{ start, end });
|
|
56
|
+
lastLine = end;
|
|
57
|
+
} else if (isLastChange && isNextEmptyLine) {
|
|
58
|
+
removed.push(lastLine + 1 /* = empty line */);
|
|
59
|
+
} else {
|
|
60
|
+
// default case is a modification
|
|
61
|
+
const start = lastLine + 1;
|
|
62
|
+
const end = lastLine + next.count!;
|
|
63
|
+
modified.push(<LineRange>{ start, end });
|
|
64
|
+
lastLine = end;
|
|
65
|
+
}
|
|
66
|
+
i++; // consume next eagerly
|
|
67
|
+
} else if (change.removed && !(next && next.added)) {
|
|
68
|
+
removed.push(Math.max(0, lastLine));
|
|
69
|
+
} else {
|
|
70
|
+
lastLine += change.count!;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return <DirtyDiff>{ added, removed, modified };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class ArrayDiff extends jsdiff.Diff {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
override tokenize(value: any): any {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
override join(value: any): any {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
override removeEmpty(value: any): any {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const arrayDiff = new ArrayDiff();
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Computes diff without copying data.
|
|
97
|
+
*/
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
function diffArrays(oldArr: ContentLinesArrayLike, newArr: ContentLinesArrayLike): DiffResult[] {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
return arrayDiff.diff(oldArr as any, newArr as any) as any;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface DiffResult {
|
|
105
|
+
value: [number, number];
|
|
106
|
+
count?: number;
|
|
107
|
+
added?: boolean;
|
|
108
|
+
removed?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface DirtyDiff {
|
|
112
|
+
/**
|
|
113
|
+
* Lines added by comparison to previous revision.
|
|
114
|
+
*/
|
|
115
|
+
readonly added: LineRange[];
|
|
116
|
+
/**
|
|
117
|
+
* Lines, after which lines were removed by comparison to previous revision.
|
|
118
|
+
*/
|
|
119
|
+
readonly removed: number[];
|
|
120
|
+
/**
|
|
121
|
+
* Lines modified by comparison to previous revision.
|
|
122
|
+
*/
|
|
123
|
+
readonly modified: LineRange[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface LineRange {
|
|
127
|
+
start: number;
|
|
128
|
+
end: number;
|
|
129
|
+
}
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
Range,
|
|
20
|
-
Position,
|
|
21
|
-
EditorDecoration,
|
|
22
|
-
EditorDecorationOptions,
|
|
23
|
-
OverviewRulerLane,
|
|
24
|
-
EditorDecorator,
|
|
25
|
-
TextEditor,
|
|
26
|
-
MinimapPosition
|
|
27
|
-
} from '@theia/editor/lib/browser';
|
|
28
|
-
import { DirtyDiff, LineRange } from './diff-computer';
|
|
29
|
-
|
|
30
|
-
export enum DirtyDiffDecorationType {
|
|
31
|
-
AddedLine = 'dirty-diff-added-line',
|
|
32
|
-
RemovedLine = 'dirty-diff-removed-line',
|
|
33
|
-
ModifiedLine = 'dirty-diff-modified-line',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const AddedLineDecoration = <EditorDecorationOptions>{
|
|
37
|
-
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-added-line',
|
|
38
|
-
overviewRuler: {
|
|
39
|
-
color: {
|
|
40
|
-
id: 'editorOverviewRuler.addedForeground'
|
|
41
|
-
},
|
|
42
|
-
position: OverviewRulerLane.Left,
|
|
43
|
-
},
|
|
44
|
-
minimap: {
|
|
45
|
-
color: {
|
|
46
|
-
id: 'minimapGutter.addedBackground'
|
|
47
|
-
},
|
|
48
|
-
position: MinimapPosition.Gutter
|
|
49
|
-
},
|
|
50
|
-
isWholeLine: true
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const RemovedLineDecoration = <EditorDecorationOptions>{
|
|
54
|
-
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-removed-line',
|
|
55
|
-
overviewRuler: {
|
|
56
|
-
color: {
|
|
57
|
-
id: 'editorOverviewRuler.deletedForeground'
|
|
58
|
-
},
|
|
59
|
-
position: OverviewRulerLane.Left,
|
|
60
|
-
},
|
|
61
|
-
minimap: {
|
|
62
|
-
color: {
|
|
63
|
-
id: 'minimapGutter.deletedBackground'
|
|
64
|
-
},
|
|
65
|
-
position: MinimapPosition.Gutter
|
|
66
|
-
},
|
|
67
|
-
isWholeLine: false
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const ModifiedLineDecoration = <EditorDecorationOptions>{
|
|
71
|
-
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-modified-line',
|
|
72
|
-
overviewRuler: {
|
|
73
|
-
color: {
|
|
74
|
-
id: 'editorOverviewRuler.modifiedForeground'
|
|
75
|
-
},
|
|
76
|
-
position: OverviewRulerLane.Left,
|
|
77
|
-
},
|
|
78
|
-
minimap: {
|
|
79
|
-
color: {
|
|
80
|
-
id: 'minimapGutter.modifiedBackground'
|
|
81
|
-
},
|
|
82
|
-
position: MinimapPosition.Gutter
|
|
83
|
-
},
|
|
84
|
-
isWholeLine: true
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export interface DirtyDiffUpdate extends DirtyDiff {
|
|
88
|
-
readonly editor: TextEditor;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@injectable()
|
|
92
|
-
export class DirtyDiffDecorator extends EditorDecorator {
|
|
93
|
-
|
|
94
|
-
applyDecorations(update: DirtyDiffUpdate): void {
|
|
95
|
-
const modifications = update.modified.map(range => this.toDeltaDecoration(range, ModifiedLineDecoration));
|
|
96
|
-
const additions = update.added.map(range => this.toDeltaDecoration(range, AddedLineDecoration));
|
|
97
|
-
const removals = update.removed.map(line => this.toDeltaDecoration(line, RemovedLineDecoration));
|
|
98
|
-
const decorations = [...modifications, ...additions, ...removals];
|
|
99
|
-
this.setDecorations(update.editor, decorations);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
protected toDeltaDecoration(from: LineRange | number, options: EditorDecorationOptions): EditorDecoration {
|
|
103
|
-
const [start, end] = (typeof from === 'number') ? [from, from] : [from.start, from.end];
|
|
104
|
-
const range = Range.create(Position.create(start, 0), Position.create(end, 0));
|
|
105
|
-
return { range, options };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import {
|
|
19
|
+
Range,
|
|
20
|
+
Position,
|
|
21
|
+
EditorDecoration,
|
|
22
|
+
EditorDecorationOptions,
|
|
23
|
+
OverviewRulerLane,
|
|
24
|
+
EditorDecorator,
|
|
25
|
+
TextEditor,
|
|
26
|
+
MinimapPosition
|
|
27
|
+
} from '@theia/editor/lib/browser';
|
|
28
|
+
import { DirtyDiff, LineRange } from './diff-computer';
|
|
29
|
+
|
|
30
|
+
export enum DirtyDiffDecorationType {
|
|
31
|
+
AddedLine = 'dirty-diff-added-line',
|
|
32
|
+
RemovedLine = 'dirty-diff-removed-line',
|
|
33
|
+
ModifiedLine = 'dirty-diff-modified-line',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const AddedLineDecoration = <EditorDecorationOptions>{
|
|
37
|
+
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-added-line',
|
|
38
|
+
overviewRuler: {
|
|
39
|
+
color: {
|
|
40
|
+
id: 'editorOverviewRuler.addedForeground'
|
|
41
|
+
},
|
|
42
|
+
position: OverviewRulerLane.Left,
|
|
43
|
+
},
|
|
44
|
+
minimap: {
|
|
45
|
+
color: {
|
|
46
|
+
id: 'minimapGutter.addedBackground'
|
|
47
|
+
},
|
|
48
|
+
position: MinimapPosition.Gutter
|
|
49
|
+
},
|
|
50
|
+
isWholeLine: true
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const RemovedLineDecoration = <EditorDecorationOptions>{
|
|
54
|
+
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-removed-line',
|
|
55
|
+
overviewRuler: {
|
|
56
|
+
color: {
|
|
57
|
+
id: 'editorOverviewRuler.deletedForeground'
|
|
58
|
+
},
|
|
59
|
+
position: OverviewRulerLane.Left,
|
|
60
|
+
},
|
|
61
|
+
minimap: {
|
|
62
|
+
color: {
|
|
63
|
+
id: 'minimapGutter.deletedBackground'
|
|
64
|
+
},
|
|
65
|
+
position: MinimapPosition.Gutter
|
|
66
|
+
},
|
|
67
|
+
isWholeLine: false
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const ModifiedLineDecoration = <EditorDecorationOptions>{
|
|
71
|
+
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-modified-line',
|
|
72
|
+
overviewRuler: {
|
|
73
|
+
color: {
|
|
74
|
+
id: 'editorOverviewRuler.modifiedForeground'
|
|
75
|
+
},
|
|
76
|
+
position: OverviewRulerLane.Left,
|
|
77
|
+
},
|
|
78
|
+
minimap: {
|
|
79
|
+
color: {
|
|
80
|
+
id: 'minimapGutter.modifiedBackground'
|
|
81
|
+
},
|
|
82
|
+
position: MinimapPosition.Gutter
|
|
83
|
+
},
|
|
84
|
+
isWholeLine: true
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export interface DirtyDiffUpdate extends DirtyDiff {
|
|
88
|
+
readonly editor: TextEditor;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@injectable()
|
|
92
|
+
export class DirtyDiffDecorator extends EditorDecorator {
|
|
93
|
+
|
|
94
|
+
applyDecorations(update: DirtyDiffUpdate): void {
|
|
95
|
+
const modifications = update.modified.map(range => this.toDeltaDecoration(range, ModifiedLineDecoration));
|
|
96
|
+
const additions = update.added.map(range => this.toDeltaDecoration(range, AddedLineDecoration));
|
|
97
|
+
const removals = update.removed.map(line => this.toDeltaDecoration(line, RemovedLineDecoration));
|
|
98
|
+
const decorations = [...modifications, ...additions, ...removals];
|
|
99
|
+
this.setDecorations(update.editor, decorations);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected toDeltaDecoration(from: LineRange | number, options: EditorDecorationOptions): EditorDecoration {
|
|
103
|
+
const [start, end] = (typeof from === 'number') ? [from, from] : [from.start, from.end];
|
|
104
|
+
const range = Range.create(Position.create(start, 0), Position.create(end, 0));
|
|
105
|
+
return { range, options };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { DirtyDiffDecorator } from './dirty-diff-decorator';
|
|
19
|
-
|
|
20
|
-
import '../../../src/browser/style/dirty-diff.css';
|
|
21
|
-
|
|
22
|
-
export function bindDirtyDiff(bind: interfaces.Bind): void {
|
|
23
|
-
bind(DirtyDiffDecorator).toSelf().inSingletonScope();
|
|
24
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
+
import { DirtyDiffDecorator } from './dirty-diff-decorator';
|
|
19
|
+
|
|
20
|
+
import '../../../src/browser/style/dirty-diff.css';
|
|
21
|
+
|
|
22
|
+
export function bindDirtyDiff(bind: interfaces.Bind): void {
|
|
23
|
+
bind(DirtyDiffDecorator).toSelf().inSingletonScope();
|
|
24
|
+
}
|