@theia/scm 1.53.0-next.4 → 1.53.0-next.55

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.
Files changed (41) hide show
  1. package/README.md +31 -31
  2. package/lib/browser/scm-commit-widget.js +1 -1
  3. package/lib/browser/scm-contribution.js +5 -5
  4. package/package.json +7 -7
  5. package/src/browser/decorations/scm-decorations-service.ts +102 -102
  6. package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
  7. package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
  8. package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
  9. package/src/browser/dirty-diff/content-lines.ts +121 -121
  10. package/src/browser/dirty-diff/diff-computer.spec.ts +455 -455
  11. package/src/browser/dirty-diff/diff-computer.ts +177 -177
  12. package/src/browser/dirty-diff/dirty-diff-decorator.ts +114 -114
  13. package/src/browser/dirty-diff/dirty-diff-module.ts +33 -33
  14. package/src/browser/dirty-diff/dirty-diff-navigator.ts +288 -288
  15. package/src/browser/dirty-diff/dirty-diff-widget.ts +364 -364
  16. package/src/browser/scm-amend-component.tsx +600 -600
  17. package/src/browser/scm-amend-widget.tsx +77 -77
  18. package/src/browser/scm-avatar-service.ts +27 -27
  19. package/src/browser/scm-colors.ts +21 -21
  20. package/src/browser/scm-commit-widget.tsx +215 -215
  21. package/src/browser/scm-context-key-service.ts +46 -46
  22. package/src/browser/scm-contribution.ts +452 -452
  23. package/src/browser/scm-frontend-module.ts +149 -149
  24. package/src/browser/scm-groups-tree-model.ts +78 -78
  25. package/src/browser/scm-input.ts +164 -164
  26. package/src/browser/scm-layout-migrations.ts +64 -64
  27. package/src/browser/scm-no-repository-widget.tsx +41 -41
  28. package/src/browser/scm-preferences.ts +63 -63
  29. package/src/browser/scm-provider.ts +91 -91
  30. package/src/browser/scm-quick-open-service.ts +48 -48
  31. package/src/browser/scm-repository.ts +52 -52
  32. package/src/browser/scm-service.ts +108 -108
  33. package/src/browser/scm-tree-label-provider.ts +44 -44
  34. package/src/browser/scm-tree-model.ts +405 -405
  35. package/src/browser/scm-tree-widget.tsx +838 -838
  36. package/src/browser/scm-widget.tsx +204 -204
  37. package/src/browser/style/dirty-diff-decorator.css +53 -53
  38. package/src/browser/style/dirty-diff.css +50 -50
  39. package/src/browser/style/index.css +271 -271
  40. package/src/browser/style/scm-amend-component.css +94 -94
  41. package/src/browser/style/scm.svg +4 -4
@@ -1,177 +1,177 @@
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
- import { Position, Range, uinteger } from '@theia/core/shared/vscode-languageserver-protocol';
20
-
21
- export class DiffComputer {
22
-
23
- computeDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DiffResult[] {
24
- const diffResult = diffArrays(previous, current);
25
- return diffResult;
26
- }
27
-
28
- computeDirtyDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DirtyDiff {
29
- const changes: Change[] = [];
30
- const diffResult = this.computeDiff(previous, current);
31
- let currentRevisionLine = -1;
32
- let previousRevisionLine = -1;
33
- for (let i = 0; i < diffResult.length; i++) {
34
- const change = diffResult[i];
35
- const next = diffResult[i + 1];
36
- if (change.added) {
37
- // case: addition
38
- changes.push({ previousRange: LineRange.createEmptyLineRange(previousRevisionLine + 1), currentRange: toLineRange(change) });
39
- currentRevisionLine += change.count!;
40
- } else if (change.removed && next && next.added) {
41
- const isFirstChange = i === 0;
42
- const isLastChange = i === diffResult.length - 2;
43
- const isNextEmptyLine = next.value.length > 0 && current[next.value[0]].length === 0;
44
- const isPrevEmptyLine = change.value.length > 0 && previous[change.value[0]].length === 0;
45
-
46
- if (isFirstChange && isNextEmptyLine) {
47
- // special case: removing at the beginning
48
- changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(0) });
49
- previousRevisionLine += change.count!;
50
- } else if (isFirstChange && isPrevEmptyLine) {
51
- // special case: adding at the beginning
52
- changes.push({ previousRange: LineRange.createEmptyLineRange(0), currentRange: toLineRange(next) });
53
- currentRevisionLine += next.count!;
54
- } else if (isLastChange && isNextEmptyLine) {
55
- changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(currentRevisionLine + 2) });
56
- previousRevisionLine += change.count!;
57
- } else {
58
- // default case is a modification
59
- changes.push({ previousRange: toLineRange(change), currentRange: toLineRange(next) });
60
- currentRevisionLine += next.count!;
61
- previousRevisionLine += change.count!;
62
- }
63
- i++; // consume next eagerly
64
- } else if (change.removed && !(next && next.added)) {
65
- // case: removal
66
- changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(currentRevisionLine + 1) });
67
- previousRevisionLine += change.count!;
68
- } else {
69
- // case: unchanged region
70
- currentRevisionLine += change.count!;
71
- previousRevisionLine += change.count!;
72
- }
73
- }
74
- return { changes };
75
- }
76
-
77
- }
78
-
79
- class ArrayDiff extends jsdiff.Diff {
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- override tokenize(value: any): any {
82
- return value;
83
- }
84
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- override join(value: any): any {
86
- return value;
87
- }
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- override removeEmpty(value: any): any {
90
- return value;
91
- }
92
- }
93
-
94
- const arrayDiff = new ArrayDiff();
95
-
96
- /**
97
- * Computes diff without copying data.
98
- */
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- function diffArrays(oldArr: ContentLinesArrayLike, newArr: ContentLinesArrayLike): DiffResult[] {
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
- return arrayDiff.diff(oldArr as any, newArr as any) as any;
103
- }
104
-
105
- function toLineRange({ value }: DiffResult): LineRange {
106
- const [start, end] = value;
107
- return LineRange.create(start, end + 1);
108
- }
109
-
110
- export interface DiffResult {
111
- value: [number, number];
112
- count?: number;
113
- added?: boolean;
114
- removed?: boolean;
115
- }
116
-
117
- export interface DirtyDiff {
118
- readonly changes: readonly Change[];
119
- }
120
-
121
- export interface Change {
122
- readonly previousRange: LineRange;
123
- readonly currentRange: LineRange;
124
- }
125
-
126
- export namespace Change {
127
- export function isAddition(change: Change): boolean {
128
- return LineRange.isEmpty(change.previousRange);
129
- }
130
- export function isRemoval(change: Change): boolean {
131
- return LineRange.isEmpty(change.currentRange);
132
- }
133
- export function isModification(change: Change): boolean {
134
- return !isAddition(change) && !isRemoval(change);
135
- }
136
- }
137
-
138
- export interface LineRange {
139
- readonly start: number;
140
- readonly end: number;
141
- }
142
-
143
- export namespace LineRange {
144
- export function create(start: number, end: number): LineRange {
145
- if (start < 0 || end < 0 || start > end) {
146
- throw new Error(`Invalid line range: { start: ${start}, end: ${end} }`);
147
- }
148
- return { start, end };
149
- }
150
- export function createSingleLineRange(line: number): LineRange {
151
- return create(line, line + 1);
152
- }
153
- export function createEmptyLineRange(line: number): LineRange {
154
- return create(line, line);
155
- }
156
- export function isEmpty(range: LineRange): boolean {
157
- return range.start === range.end;
158
- }
159
- export function getStartPosition(range: LineRange): Position {
160
- if (isEmpty(range)) {
161
- return getEndPosition(range);
162
- }
163
- return Position.create(range.start, 0);
164
- }
165
- export function getEndPosition(range: LineRange): Position {
166
- if (range.end < 1) {
167
- return Position.create(0, 0);
168
- }
169
- return Position.create(range.end - 1, uinteger.MAX_VALUE);
170
- }
171
- export function toRange(range: LineRange): Range {
172
- return Range.create(getStartPosition(range), getEndPosition(range));
173
- }
174
- export function getLineCount(range: LineRange): number {
175
- return range.end - range.start;
176
- }
177
- }
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
+ import { Position, Range, uinteger } from '@theia/core/shared/vscode-languageserver-protocol';
20
+
21
+ export class DiffComputer {
22
+
23
+ computeDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DiffResult[] {
24
+ const diffResult = diffArrays(previous, current);
25
+ return diffResult;
26
+ }
27
+
28
+ computeDirtyDiff(previous: ContentLinesArrayLike, current: ContentLinesArrayLike): DirtyDiff {
29
+ const changes: Change[] = [];
30
+ const diffResult = this.computeDiff(previous, current);
31
+ let currentRevisionLine = -1;
32
+ let previousRevisionLine = -1;
33
+ for (let i = 0; i < diffResult.length; i++) {
34
+ const change = diffResult[i];
35
+ const next = diffResult[i + 1];
36
+ if (change.added) {
37
+ // case: addition
38
+ changes.push({ previousRange: LineRange.createEmptyLineRange(previousRevisionLine + 1), currentRange: toLineRange(change) });
39
+ currentRevisionLine += change.count!;
40
+ } else if (change.removed && next && next.added) {
41
+ const isFirstChange = i === 0;
42
+ const isLastChange = i === diffResult.length - 2;
43
+ const isNextEmptyLine = next.value.length > 0 && current[next.value[0]].length === 0;
44
+ const isPrevEmptyLine = change.value.length > 0 && previous[change.value[0]].length === 0;
45
+
46
+ if (isFirstChange && isNextEmptyLine) {
47
+ // special case: removing at the beginning
48
+ changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(0) });
49
+ previousRevisionLine += change.count!;
50
+ } else if (isFirstChange && isPrevEmptyLine) {
51
+ // special case: adding at the beginning
52
+ changes.push({ previousRange: LineRange.createEmptyLineRange(0), currentRange: toLineRange(next) });
53
+ currentRevisionLine += next.count!;
54
+ } else if (isLastChange && isNextEmptyLine) {
55
+ changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(currentRevisionLine + 2) });
56
+ previousRevisionLine += change.count!;
57
+ } else {
58
+ // default case is a modification
59
+ changes.push({ previousRange: toLineRange(change), currentRange: toLineRange(next) });
60
+ currentRevisionLine += next.count!;
61
+ previousRevisionLine += change.count!;
62
+ }
63
+ i++; // consume next eagerly
64
+ } else if (change.removed && !(next && next.added)) {
65
+ // case: removal
66
+ changes.push({ previousRange: toLineRange(change), currentRange: LineRange.createEmptyLineRange(currentRevisionLine + 1) });
67
+ previousRevisionLine += change.count!;
68
+ } else {
69
+ // case: unchanged region
70
+ currentRevisionLine += change.count!;
71
+ previousRevisionLine += change.count!;
72
+ }
73
+ }
74
+ return { changes };
75
+ }
76
+
77
+ }
78
+
79
+ class ArrayDiff extends jsdiff.Diff {
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ override tokenize(value: any): any {
82
+ return value;
83
+ }
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ override join(value: any): any {
86
+ return value;
87
+ }
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ override removeEmpty(value: any): any {
90
+ return value;
91
+ }
92
+ }
93
+
94
+ const arrayDiff = new ArrayDiff();
95
+
96
+ /**
97
+ * Computes diff without copying data.
98
+ */
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ function diffArrays(oldArr: ContentLinesArrayLike, newArr: ContentLinesArrayLike): DiffResult[] {
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ return arrayDiff.diff(oldArr as any, newArr as any) as any;
103
+ }
104
+
105
+ function toLineRange({ value }: DiffResult): LineRange {
106
+ const [start, end] = value;
107
+ return LineRange.create(start, end + 1);
108
+ }
109
+
110
+ export interface DiffResult {
111
+ value: [number, number];
112
+ count?: number;
113
+ added?: boolean;
114
+ removed?: boolean;
115
+ }
116
+
117
+ export interface DirtyDiff {
118
+ readonly changes: readonly Change[];
119
+ }
120
+
121
+ export interface Change {
122
+ readonly previousRange: LineRange;
123
+ readonly currentRange: LineRange;
124
+ }
125
+
126
+ export namespace Change {
127
+ export function isAddition(change: Change): boolean {
128
+ return LineRange.isEmpty(change.previousRange);
129
+ }
130
+ export function isRemoval(change: Change): boolean {
131
+ return LineRange.isEmpty(change.currentRange);
132
+ }
133
+ export function isModification(change: Change): boolean {
134
+ return !isAddition(change) && !isRemoval(change);
135
+ }
136
+ }
137
+
138
+ export interface LineRange {
139
+ readonly start: number;
140
+ readonly end: number;
141
+ }
142
+
143
+ export namespace LineRange {
144
+ export function create(start: number, end: number): LineRange {
145
+ if (start < 0 || end < 0 || start > end) {
146
+ throw new Error(`Invalid line range: { start: ${start}, end: ${end} }`);
147
+ }
148
+ return { start, end };
149
+ }
150
+ export function createSingleLineRange(line: number): LineRange {
151
+ return create(line, line + 1);
152
+ }
153
+ export function createEmptyLineRange(line: number): LineRange {
154
+ return create(line, line);
155
+ }
156
+ export function isEmpty(range: LineRange): boolean {
157
+ return range.start === range.end;
158
+ }
159
+ export function getStartPosition(range: LineRange): Position {
160
+ if (isEmpty(range)) {
161
+ return getEndPosition(range);
162
+ }
163
+ return Position.create(range.start, 0);
164
+ }
165
+ export function getEndPosition(range: LineRange): Position {
166
+ if (range.end < 1) {
167
+ return Position.create(0, 0);
168
+ }
169
+ return Position.create(range.end - 1, uinteger.MAX_VALUE);
170
+ }
171
+ export function toRange(range: LineRange): Range {
172
+ return Range.create(getStartPosition(range), getEndPosition(range));
173
+ }
174
+ export function getLineCount(range: LineRange): number {
175
+ return range.end - range.start;
176
+ }
177
+ }
@@ -1,114 +1,114 @@
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
- EditorDecoration,
20
- EditorDecorationOptions,
21
- OverviewRulerLane,
22
- EditorDecorator,
23
- TextEditor,
24
- MinimapPosition
25
- } from '@theia/editor/lib/browser';
26
- import { DirtyDiff, LineRange, Change } from './diff-computer';
27
- import { URI } from '@theia/core';
28
-
29
- export enum DirtyDiffDecorationType {
30
- AddedLine = 'dirty-diff-added-line',
31
- RemovedLine = 'dirty-diff-removed-line',
32
- ModifiedLine = 'dirty-diff-modified-line',
33
- }
34
-
35
- const AddedLineDecoration = <EditorDecorationOptions>{
36
- linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-added-line',
37
- overviewRuler: {
38
- color: {
39
- id: 'editorOverviewRuler.addedForeground'
40
- },
41
- position: OverviewRulerLane.Left,
42
- },
43
- minimap: {
44
- color: {
45
- id: 'minimapGutter.addedBackground'
46
- },
47
- position: MinimapPosition.Gutter
48
- },
49
- isWholeLine: true
50
- };
51
-
52
- const RemovedLineDecoration = <EditorDecorationOptions>{
53
- linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-removed-line',
54
- overviewRuler: {
55
- color: {
56
- id: 'editorOverviewRuler.deletedForeground'
57
- },
58
- position: OverviewRulerLane.Left,
59
- },
60
- minimap: {
61
- color: {
62
- id: 'minimapGutter.deletedBackground'
63
- },
64
- position: MinimapPosition.Gutter
65
- },
66
- isWholeLine: false
67
- };
68
-
69
- const ModifiedLineDecoration = <EditorDecorationOptions>{
70
- linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-modified-line',
71
- overviewRuler: {
72
- color: {
73
- id: 'editorOverviewRuler.modifiedForeground'
74
- },
75
- position: OverviewRulerLane.Left,
76
- },
77
- minimap: {
78
- color: {
79
- id: 'minimapGutter.modifiedBackground'
80
- },
81
- position: MinimapPosition.Gutter
82
- },
83
- isWholeLine: true
84
- };
85
-
86
- function getEditorDecorationOptions(change: Change): EditorDecorationOptions {
87
- if (Change.isAddition(change)) {
88
- return AddedLineDecoration;
89
- }
90
- if (Change.isRemoval(change)) {
91
- return RemovedLineDecoration;
92
- }
93
- return ModifiedLineDecoration;
94
- }
95
-
96
- export interface DirtyDiffUpdate extends DirtyDiff {
97
- readonly editor: TextEditor;
98
- readonly previousRevisionUri?: URI;
99
- }
100
-
101
- @injectable()
102
- export class DirtyDiffDecorator extends EditorDecorator {
103
-
104
- applyDecorations(update: DirtyDiffUpdate): void {
105
- const decorations = update.changes.map(change => this.toDeltaDecoration(change));
106
- this.setDecorations(update.editor, decorations);
107
- }
108
-
109
- protected toDeltaDecoration(change: Change): EditorDecoration {
110
- const range = LineRange.toRange(change.currentRange);
111
- const options = getEditorDecorationOptions(change);
112
- return { range, options };
113
- }
114
- }
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
+ EditorDecoration,
20
+ EditorDecorationOptions,
21
+ OverviewRulerLane,
22
+ EditorDecorator,
23
+ TextEditor,
24
+ MinimapPosition
25
+ } from '@theia/editor/lib/browser';
26
+ import { DirtyDiff, LineRange, Change } from './diff-computer';
27
+ import { URI } from '@theia/core';
28
+
29
+ export enum DirtyDiffDecorationType {
30
+ AddedLine = 'dirty-diff-added-line',
31
+ RemovedLine = 'dirty-diff-removed-line',
32
+ ModifiedLine = 'dirty-diff-modified-line',
33
+ }
34
+
35
+ const AddedLineDecoration = <EditorDecorationOptions>{
36
+ linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-added-line',
37
+ overviewRuler: {
38
+ color: {
39
+ id: 'editorOverviewRuler.addedForeground'
40
+ },
41
+ position: OverviewRulerLane.Left,
42
+ },
43
+ minimap: {
44
+ color: {
45
+ id: 'minimapGutter.addedBackground'
46
+ },
47
+ position: MinimapPosition.Gutter
48
+ },
49
+ isWholeLine: true
50
+ };
51
+
52
+ const RemovedLineDecoration = <EditorDecorationOptions>{
53
+ linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-removed-line',
54
+ overviewRuler: {
55
+ color: {
56
+ id: 'editorOverviewRuler.deletedForeground'
57
+ },
58
+ position: OverviewRulerLane.Left,
59
+ },
60
+ minimap: {
61
+ color: {
62
+ id: 'minimapGutter.deletedBackground'
63
+ },
64
+ position: MinimapPosition.Gutter
65
+ },
66
+ isWholeLine: false
67
+ };
68
+
69
+ const ModifiedLineDecoration = <EditorDecorationOptions>{
70
+ linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-modified-line',
71
+ overviewRuler: {
72
+ color: {
73
+ id: 'editorOverviewRuler.modifiedForeground'
74
+ },
75
+ position: OverviewRulerLane.Left,
76
+ },
77
+ minimap: {
78
+ color: {
79
+ id: 'minimapGutter.modifiedBackground'
80
+ },
81
+ position: MinimapPosition.Gutter
82
+ },
83
+ isWholeLine: true
84
+ };
85
+
86
+ function getEditorDecorationOptions(change: Change): EditorDecorationOptions {
87
+ if (Change.isAddition(change)) {
88
+ return AddedLineDecoration;
89
+ }
90
+ if (Change.isRemoval(change)) {
91
+ return RemovedLineDecoration;
92
+ }
93
+ return ModifiedLineDecoration;
94
+ }
95
+
96
+ export interface DirtyDiffUpdate extends DirtyDiff {
97
+ readonly editor: TextEditor;
98
+ readonly previousRevisionUri?: URI;
99
+ }
100
+
101
+ @injectable()
102
+ export class DirtyDiffDecorator extends EditorDecorator {
103
+
104
+ applyDecorations(update: DirtyDiffUpdate): void {
105
+ const decorations = update.changes.map(change => this.toDeltaDecoration(change));
106
+ this.setDecorations(update.editor, decorations);
107
+ }
108
+
109
+ protected toDeltaDecoration(change: Change): EditorDecoration {
110
+ const range = LineRange.toRange(change.currentRange);
111
+ const options = getEditorDecorationOptions(change);
112
+ return { range, options };
113
+ }
114
+ }
@@ -1,33 +1,33 @@
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
- import { DirtyDiffNavigator } from './dirty-diff-navigator';
20
- import { DirtyDiffWidget, DirtyDiffWidgetFactory, DirtyDiffWidgetProps } from './dirty-diff-widget';
21
-
22
- import '../../../src/browser/style/dirty-diff.css';
23
-
24
- export function bindDirtyDiff(bind: interfaces.Bind): void {
25
- bind(DirtyDiffDecorator).toSelf().inSingletonScope();
26
- bind(DirtyDiffNavigator).toSelf().inSingletonScope();
27
- bind(DirtyDiffWidgetFactory).toFactory(({ container }) => props => {
28
- const child = container.createChild();
29
- child.bind(DirtyDiffWidgetProps).toConstantValue(props);
30
- child.bind(DirtyDiffWidget).toSelf();
31
- return child.get(DirtyDiffWidget);
32
- });
33
- }
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
+ import { DirtyDiffNavigator } from './dirty-diff-navigator';
20
+ import { DirtyDiffWidget, DirtyDiffWidgetFactory, DirtyDiffWidgetProps } from './dirty-diff-widget';
21
+
22
+ import '../../../src/browser/style/dirty-diff.css';
23
+
24
+ export function bindDirtyDiff(bind: interfaces.Bind): void {
25
+ bind(DirtyDiffDecorator).toSelf().inSingletonScope();
26
+ bind(DirtyDiffNavigator).toSelf().inSingletonScope();
27
+ bind(DirtyDiffWidgetFactory).toFactory(({ container }) => props => {
28
+ const child = container.createChild();
29
+ child.bind(DirtyDiffWidgetProps).toConstantValue(props);
30
+ child.bind(DirtyDiffWidget).toSelf();
31
+ return child.get(DirtyDiffWidget);
32
+ });
33
+ }