@codingame/monaco-vscode-scm-service-override 36.2.7 → 37.1.0
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/index.js +1 -1
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/activity.js +5 -5
- package/vscode/src/vs/workbench/contrib/scm/browser/media/dirtydiffDecorator.css +173 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/media/scm.css +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/menus.js +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiff.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiff.contribution.js +105 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffDecorator.d.ts +36 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffDecorator.js +430 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffModel.js +3 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffWidget.d.ts +80 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffWidget.js +933 -0
- package/vscode/src/vs/workbench/contrib/scm/browser/scm.contribution.js +71 -71
- package/vscode/src/vs/workbench/contrib/scm/browser/scmAccessibilityHelp.js +23 -23
- package/vscode/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.js +26 -26
- package/vscode/src/vs/workbench/contrib/scm/browser/scmInput.js +6 -6
- package/vscode/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.js +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewPane.js +21 -21
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewService.js +1 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
|
|
2
|
+
import { registerCss } from '@codingame/monaco-vscode-api/css';
|
|
3
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
4
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
+
import * as dirtydiffDecorator from './media/dirtydiffDecorator.css';
|
|
6
|
+
import { Disposable, DisposableStore, DisposableMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
8
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
9
|
+
import { ModelDecorationOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
|
|
10
|
+
import { themeColorFromId } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService';
|
|
11
|
+
import { isCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
|
|
12
|
+
import { OverviewRulerLane, MinimapPosition } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
|
|
13
|
+
import { createStyleSheet } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
|
|
14
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
15
|
+
import { minimapGutterAddedBackground, overviewRulerAddedForeground, minimapGutterModifiedBackground, overviewRulerModifiedForeground, minimapGutterDeletedBackground, overviewRulerDeletedForeground, getChangeType, ChangeType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff';
|
|
16
|
+
import { IQuickDiffService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff.service';
|
|
17
|
+
import { IQuickDiffModelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/browser/quickDiffModel.service';
|
|
18
|
+
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
19
|
+
import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
20
|
+
import { RawContextKey, ContextKeyTrueExpr, ContextKeyFalseExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
21
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
22
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
23
|
+
import { registerAction2, Action2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
24
|
+
import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
|
|
25
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
26
|
+
|
|
27
|
+
var QuickDiffDecorator_1;
|
|
28
|
+
registerCss(dirtydiffDecorator);
|
|
29
|
+
const quickDiffDecorationCount = ( new RawContextKey("quickDiffDecorationCount", 0));
|
|
30
|
+
let QuickDiffDecorator = QuickDiffDecorator_1 = class QuickDiffDecorator extends Disposable {
|
|
31
|
+
static createDecoration(className, tooltip, options) {
|
|
32
|
+
const decorationOptions = {
|
|
33
|
+
description: "dirty-diff-decoration",
|
|
34
|
+
isWholeLine: options.isWholeLine
|
|
35
|
+
};
|
|
36
|
+
if (options.gutter) {
|
|
37
|
+
decorationOptions.linesDecorationsClassName = `dirty-diff-glyph ${className}`;
|
|
38
|
+
decorationOptions.linesDecorationsTooltip = tooltip;
|
|
39
|
+
}
|
|
40
|
+
if (options.overview.active) {
|
|
41
|
+
decorationOptions.overviewRuler = {
|
|
42
|
+
color: themeColorFromId(options.overview.color),
|
|
43
|
+
position: OverviewRulerLane.Left
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (options.minimap.active) {
|
|
47
|
+
decorationOptions.minimap = {
|
|
48
|
+
color: themeColorFromId(options.minimap.color),
|
|
49
|
+
position: MinimapPosition.Gutter
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return ModelDecorationOptions.createDynamic(decorationOptions);
|
|
53
|
+
}
|
|
54
|
+
constructor(codeEditor, quickDiffModelRef, configurationService, quickDiffService) {
|
|
55
|
+
super();
|
|
56
|
+
this.codeEditor = codeEditor;
|
|
57
|
+
this.quickDiffModelRef = quickDiffModelRef;
|
|
58
|
+
this.configurationService = configurationService;
|
|
59
|
+
this.quickDiffService = quickDiffService;
|
|
60
|
+
const decorations = configurationService.getValue("scm.diffDecorations");
|
|
61
|
+
const gutter = decorations === "all" || decorations === "gutter";
|
|
62
|
+
const overview = decorations === "all" || decorations === "overview";
|
|
63
|
+
const minimap = decorations === "all" || decorations === "minimap";
|
|
64
|
+
const diffAdded = ( localize(15650, "Added lines"));
|
|
65
|
+
const diffAddedOptions = {
|
|
66
|
+
gutter,
|
|
67
|
+
overview: {
|
|
68
|
+
active: overview,
|
|
69
|
+
color: overviewRulerAddedForeground
|
|
70
|
+
},
|
|
71
|
+
minimap: {
|
|
72
|
+
active: minimap,
|
|
73
|
+
color: minimapGutterAddedBackground
|
|
74
|
+
},
|
|
75
|
+
isWholeLine: true
|
|
76
|
+
};
|
|
77
|
+
this.addedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added primary", diffAdded, diffAddedOptions);
|
|
78
|
+
this.addedPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added primary pattern", diffAdded, diffAddedOptions);
|
|
79
|
+
this.addedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added secondary", diffAdded, diffAddedOptions);
|
|
80
|
+
this.addedSecondaryPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added secondary pattern", diffAdded, diffAddedOptions);
|
|
81
|
+
const diffModified = ( localize(15651, "Changed lines"));
|
|
82
|
+
const diffModifiedOptions = {
|
|
83
|
+
gutter,
|
|
84
|
+
overview: {
|
|
85
|
+
active: overview,
|
|
86
|
+
color: overviewRulerModifiedForeground
|
|
87
|
+
},
|
|
88
|
+
minimap: {
|
|
89
|
+
active: minimap,
|
|
90
|
+
color: minimapGutterModifiedBackground
|
|
91
|
+
},
|
|
92
|
+
isWholeLine: true
|
|
93
|
+
};
|
|
94
|
+
this.modifiedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified primary", diffModified, diffModifiedOptions);
|
|
95
|
+
this.modifiedPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified primary pattern", diffModified, diffModifiedOptions);
|
|
96
|
+
this.modifiedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified secondary", diffModified, diffModifiedOptions);
|
|
97
|
+
this.modifiedSecondaryPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified secondary pattern", diffModified, diffModifiedOptions);
|
|
98
|
+
const diffDeleted = ( localize(15652, "Removed lines"));
|
|
99
|
+
const diffDeletedOptions = {
|
|
100
|
+
gutter,
|
|
101
|
+
overview: {
|
|
102
|
+
active: overview,
|
|
103
|
+
color: overviewRulerDeletedForeground
|
|
104
|
+
},
|
|
105
|
+
minimap: {
|
|
106
|
+
active: minimap,
|
|
107
|
+
color: minimapGutterDeletedBackground
|
|
108
|
+
},
|
|
109
|
+
isWholeLine: false
|
|
110
|
+
};
|
|
111
|
+
this.deletedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-deleted primary", diffDeleted, diffDeletedOptions);
|
|
112
|
+
this.deletedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-deleted secondary", diffDeleted, diffDeletedOptions);
|
|
113
|
+
this._register(configurationService.onDidChangeConfiguration(e => {
|
|
114
|
+
if (e.affectsConfiguration("scm.diffDecorationsGutterPattern")) {
|
|
115
|
+
this.onDidChange();
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
this._register(
|
|
119
|
+
Event.runAndSubscribe(this.quickDiffModelRef.object.onDidChange, () => this.onDidChange())
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
onDidChange() {
|
|
123
|
+
if (!this.codeEditor.hasModel()) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const pattern = this.configurationService.getValue("scm.diffDecorationsGutterPattern");
|
|
127
|
+
const primaryQuickDiff = this.quickDiffModelRef.object.quickDiffs.find(quickDiff => quickDiff.kind === "primary");
|
|
128
|
+
const primaryQuickDiffChanges = this.quickDiffModelRef.object.changes.filter(change => change.providerId === primaryQuickDiff?.id);
|
|
129
|
+
const decorations = [];
|
|
130
|
+
for (const change of this.quickDiffModelRef.object.changes) {
|
|
131
|
+
const quickDiff = this.quickDiffModelRef.object.quickDiffs.find(quickDiff => quickDiff.id === change.providerId);
|
|
132
|
+
if (!quickDiff || !this.quickDiffService.isQuickDiffProviderVisible(quickDiff.id)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (quickDiff.kind !== "primary" && ( primaryQuickDiffChanges.some(c => c.change2.modified.intersectsOrTouches(change.change2.modified)))) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const changeType = getChangeType(change.change);
|
|
139
|
+
const startLineNumber = change.change.modifiedStartLineNumber;
|
|
140
|
+
const endLineNumber = change.change.modifiedEndLineNumber || startLineNumber;
|
|
141
|
+
switch (changeType) {
|
|
142
|
+
case ChangeType.Add:
|
|
143
|
+
decorations.push({
|
|
144
|
+
range: {
|
|
145
|
+
startLineNumber: startLineNumber,
|
|
146
|
+
startColumn: 1,
|
|
147
|
+
endLineNumber: endLineNumber,
|
|
148
|
+
endColumn: 1
|
|
149
|
+
},
|
|
150
|
+
options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? pattern.added ? this.addedPatternOptions : this.addedOptions : pattern.added ? this.addedSecondaryPatternOptions : this.addedSecondaryOptions
|
|
151
|
+
});
|
|
152
|
+
break;
|
|
153
|
+
case ChangeType.Delete:
|
|
154
|
+
decorations.push({
|
|
155
|
+
range: {
|
|
156
|
+
startLineNumber: startLineNumber,
|
|
157
|
+
startColumn: Number.MAX_VALUE,
|
|
158
|
+
endLineNumber: startLineNumber,
|
|
159
|
+
endColumn: Number.MAX_VALUE
|
|
160
|
+
},
|
|
161
|
+
options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? this.deletedOptions : this.deletedSecondaryOptions
|
|
162
|
+
});
|
|
163
|
+
break;
|
|
164
|
+
case ChangeType.Modify:
|
|
165
|
+
decorations.push({
|
|
166
|
+
range: {
|
|
167
|
+
startLineNumber: startLineNumber,
|
|
168
|
+
startColumn: 1,
|
|
169
|
+
endLineNumber: endLineNumber,
|
|
170
|
+
endColumn: 1
|
|
171
|
+
},
|
|
172
|
+
options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? pattern.modified ? this.modifiedPatternOptions : this.modifiedOptions : pattern.modified ? this.modifiedSecondaryPatternOptions : this.modifiedSecondaryOptions
|
|
173
|
+
});
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!this.decorationsCollection) {
|
|
178
|
+
this.decorationsCollection = this.codeEditor.createDecorationsCollection(decorations);
|
|
179
|
+
} else {
|
|
180
|
+
this.decorationsCollection.set(decorations);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
dispose() {
|
|
184
|
+
if (this.decorationsCollection) {
|
|
185
|
+
this.decorationsCollection.clear();
|
|
186
|
+
}
|
|
187
|
+
this.decorationsCollection = undefined;
|
|
188
|
+
this.quickDiffModelRef.dispose();
|
|
189
|
+
super.dispose();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
QuickDiffDecorator = QuickDiffDecorator_1 = ( __decorate([( __param(2, IConfigurationService)), ( __param(3, IQuickDiffService))], QuickDiffDecorator));
|
|
193
|
+
let QuickDiffWorkbenchController = class QuickDiffWorkbenchController extends Disposable {
|
|
194
|
+
constructor(
|
|
195
|
+
editorService,
|
|
196
|
+
configurationService,
|
|
197
|
+
quickDiffModelService,
|
|
198
|
+
quickDiffService,
|
|
199
|
+
uriIdentityService,
|
|
200
|
+
contextKeyService
|
|
201
|
+
) {
|
|
202
|
+
super();
|
|
203
|
+
this.editorService = editorService;
|
|
204
|
+
this.configurationService = configurationService;
|
|
205
|
+
this.quickDiffModelService = quickDiffModelService;
|
|
206
|
+
this.quickDiffService = quickDiffService;
|
|
207
|
+
this.uriIdentityService = uriIdentityService;
|
|
208
|
+
this.enabled = false;
|
|
209
|
+
this.decorators = ( new ResourceMap());
|
|
210
|
+
this.viewState = {
|
|
211
|
+
width: 3,
|
|
212
|
+
visibility: "always"
|
|
213
|
+
};
|
|
214
|
+
this.transientDisposables = this._register(( new DisposableStore()));
|
|
215
|
+
this.stylesheet = createStyleSheet(undefined, undefined, this._store);
|
|
216
|
+
this.quickDiffDecorationCount = quickDiffDecorationCount.bindTo(contextKeyService);
|
|
217
|
+
this.activeEditor = observableFromEvent(
|
|
218
|
+
this,
|
|
219
|
+
this.editorService.onDidActiveEditorChange,
|
|
220
|
+
() => this.editorService.activeEditor
|
|
221
|
+
);
|
|
222
|
+
this.quickDiffProviders = observableFromEvent(
|
|
223
|
+
this,
|
|
224
|
+
this.quickDiffService.onDidChangeQuickDiffProviders,
|
|
225
|
+
() => this.quickDiffService.providers
|
|
226
|
+
);
|
|
227
|
+
const onDidChangeConfiguration = Event.filter(
|
|
228
|
+
configurationService.onDidChangeConfiguration,
|
|
229
|
+
e => e.affectsConfiguration("scm.diffDecorations")
|
|
230
|
+
);
|
|
231
|
+
this._register(onDidChangeConfiguration(this.onDidChangeConfiguration, this));
|
|
232
|
+
this.onDidChangeConfiguration();
|
|
233
|
+
const onDidChangeDiffWidthConfiguration = Event.filter(
|
|
234
|
+
configurationService.onDidChangeConfiguration,
|
|
235
|
+
e => e.affectsConfiguration("scm.diffDecorationsGutterWidth")
|
|
236
|
+
);
|
|
237
|
+
this._register(
|
|
238
|
+
onDidChangeDiffWidthConfiguration(this.onDidChangeDiffWidthConfiguration, this)
|
|
239
|
+
);
|
|
240
|
+
this.onDidChangeDiffWidthConfiguration();
|
|
241
|
+
const onDidChangeDiffVisibilityConfiguration = Event.filter(
|
|
242
|
+
configurationService.onDidChangeConfiguration,
|
|
243
|
+
e => e.affectsConfiguration("scm.diffDecorationsGutterVisibility")
|
|
244
|
+
);
|
|
245
|
+
this._register(
|
|
246
|
+
onDidChangeDiffVisibilityConfiguration(this.onDidChangeDiffVisibilityConfiguration, this)
|
|
247
|
+
);
|
|
248
|
+
this.onDidChangeDiffVisibilityConfiguration();
|
|
249
|
+
}
|
|
250
|
+
onDidChangeConfiguration() {
|
|
251
|
+
const enabled = this.configurationService.getValue("scm.diffDecorations") !== "none";
|
|
252
|
+
if (enabled) {
|
|
253
|
+
this.enable();
|
|
254
|
+
} else {
|
|
255
|
+
this.disable();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
onDidChangeDiffWidthConfiguration() {
|
|
259
|
+
let width = this.configurationService.getValue("scm.diffDecorationsGutterWidth");
|
|
260
|
+
if (isNaN(width) || width <= 0 || width > 5) {
|
|
261
|
+
width = 3;
|
|
262
|
+
}
|
|
263
|
+
this.setViewState({
|
|
264
|
+
...this.viewState,
|
|
265
|
+
width
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
onDidChangeDiffVisibilityConfiguration() {
|
|
269
|
+
const visibility = this.configurationService.getValue("scm.diffDecorationsGutterVisibility");
|
|
270
|
+
this.setViewState({
|
|
271
|
+
...this.viewState,
|
|
272
|
+
visibility
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
setViewState(state) {
|
|
276
|
+
this.viewState = state;
|
|
277
|
+
this.stylesheet.textContent = `
|
|
278
|
+
.monaco-editor .dirty-diff-added,
|
|
279
|
+
.monaco-editor .dirty-diff-modified {
|
|
280
|
+
border-left-width:${state.width}px;
|
|
281
|
+
}
|
|
282
|
+
.monaco-editor .dirty-diff-added.pattern,
|
|
283
|
+
.monaco-editor .dirty-diff-added.pattern:before,
|
|
284
|
+
.monaco-editor .dirty-diff-modified.pattern,
|
|
285
|
+
.monaco-editor .dirty-diff-modified.pattern:before {
|
|
286
|
+
background-size: ${state.width}px ${state.width}px;
|
|
287
|
+
}
|
|
288
|
+
.monaco-editor .dirty-diff-added,
|
|
289
|
+
.monaco-editor .dirty-diff-modified,
|
|
290
|
+
.monaco-editor .dirty-diff-deleted {
|
|
291
|
+
opacity: ${state.visibility === "always" ? 1 : 0};
|
|
292
|
+
}
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
295
|
+
enable() {
|
|
296
|
+
if (this.enabled) {
|
|
297
|
+
this.disable();
|
|
298
|
+
}
|
|
299
|
+
this.transientDisposables.add(Event.any(
|
|
300
|
+
this.editorService.onDidCloseEditor,
|
|
301
|
+
this.editorService.onDidVisibleEditorsChange
|
|
302
|
+
)(() => this.onEditorsChanged()));
|
|
303
|
+
this.onEditorsChanged();
|
|
304
|
+
this.onDidActiveEditorChange();
|
|
305
|
+
this.onDidChangeQuickDiffProviders();
|
|
306
|
+
this.enabled = true;
|
|
307
|
+
}
|
|
308
|
+
disable() {
|
|
309
|
+
if (!this.enabled) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
this.transientDisposables.clear();
|
|
313
|
+
this.quickDiffDecorationCount.set(0);
|
|
314
|
+
for (const [uri, decoratorMap] of this.decorators.entries()) {
|
|
315
|
+
decoratorMap.dispose();
|
|
316
|
+
this.decorators.delete(uri);
|
|
317
|
+
}
|
|
318
|
+
this.enabled = false;
|
|
319
|
+
}
|
|
320
|
+
onDidActiveEditorChange() {
|
|
321
|
+
this.transientDisposables.add(autorun(reader => {
|
|
322
|
+
const activeEditor = this.activeEditor.read(reader);
|
|
323
|
+
const activeTextEditorControl = this.editorService.activeTextEditorControl;
|
|
324
|
+
if (!isCodeEditor(activeTextEditorControl) || !activeEditor?.resource) {
|
|
325
|
+
this.quickDiffDecorationCount.set(0);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const quickDiffModelRef = this.quickDiffModelService.createQuickDiffModelReference(activeEditor.resource);
|
|
329
|
+
if (!quickDiffModelRef) {
|
|
330
|
+
this.quickDiffDecorationCount.set(0);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
reader.store.add(quickDiffModelRef);
|
|
334
|
+
const visibleDecorationCount = observableFromEvent(this, quickDiffModelRef.object.onDidChange, () => {
|
|
335
|
+
const visibleQuickDiffs = quickDiffModelRef.object.quickDiffs.filter(
|
|
336
|
+
quickDiff => this.quickDiffService.isQuickDiffProviderVisible(quickDiff.id)
|
|
337
|
+
);
|
|
338
|
+
return quickDiffModelRef.object.changes.filter(change => ( visibleQuickDiffs.some(quickDiff => quickDiff.id === change.providerId))).length;
|
|
339
|
+
});
|
|
340
|
+
reader.store.add(autorun(reader => {
|
|
341
|
+
const count = visibleDecorationCount.read(reader);
|
|
342
|
+
this.quickDiffDecorationCount.set(count);
|
|
343
|
+
}));
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
onDidChangeQuickDiffProviders() {
|
|
347
|
+
this.transientDisposables.add(autorun(reader => {
|
|
348
|
+
const providers = this.quickDiffProviders.read(reader);
|
|
349
|
+
const labels = [];
|
|
350
|
+
for (let index = 0; index < providers.length; index++) {
|
|
351
|
+
const provider = providers[index];
|
|
352
|
+
if (labels.includes(provider.label)) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const visible = this.quickDiffService.isQuickDiffProviderVisible(provider.id);
|
|
356
|
+
const group = provider.kind !== "contributed" ? "0_scm" : "1_contributed";
|
|
357
|
+
const order = index + 1;
|
|
358
|
+
reader.store.add(registerAction2(class extends Action2 {
|
|
359
|
+
constructor() {
|
|
360
|
+
super({
|
|
361
|
+
id: `workbench.scm.action.toggleQuickDiffVisibility.${provider.id}`,
|
|
362
|
+
title: provider.label,
|
|
363
|
+
toggled: visible ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE,
|
|
364
|
+
menu: {
|
|
365
|
+
id: MenuId.SCMQuickDiffDecorations,
|
|
366
|
+
group,
|
|
367
|
+
order
|
|
368
|
+
},
|
|
369
|
+
f1: false
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
run(accessor) {
|
|
373
|
+
const quickDiffService = accessor.get(IQuickDiffService);
|
|
374
|
+
quickDiffService.toggleQuickDiffProviderVisibility(provider.id);
|
|
375
|
+
}
|
|
376
|
+
}));
|
|
377
|
+
labels.push(provider.label);
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
381
|
+
onEditorsChanged() {
|
|
382
|
+
for (const editor of this.editorService.visibleTextEditorControls) {
|
|
383
|
+
if (!isCodeEditor(editor)) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const textModel = editor.getModel();
|
|
387
|
+
if (!textModel) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const editorId = editor.getId();
|
|
391
|
+
if (this.decorators.get(textModel.uri)?.has(editorId)) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const quickDiffModelRef = this.quickDiffModelService.createQuickDiffModelReference(textModel.uri);
|
|
395
|
+
if (!quickDiffModelRef) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (!( this.decorators.has(textModel.uri))) {
|
|
399
|
+
this.decorators.set(textModel.uri, ( new DisposableMap()));
|
|
400
|
+
}
|
|
401
|
+
this.decorators.get(textModel.uri).set(editorId, ( new QuickDiffDecorator(
|
|
402
|
+
editor,
|
|
403
|
+
quickDiffModelRef,
|
|
404
|
+
this.configurationService,
|
|
405
|
+
this.quickDiffService
|
|
406
|
+
)));
|
|
407
|
+
}
|
|
408
|
+
for (const [uri, decoratorMap] of this.decorators.entries()) {
|
|
409
|
+
for (const editorId of ( decoratorMap.keys())) {
|
|
410
|
+
const codeEditor = this.editorService.visibleTextEditorControls.find(
|
|
411
|
+
editor => isCodeEditor(editor) && editor.getId() === editorId && this.uriIdentityService.extUri.isEqual(editor.getModel()?.uri, uri)
|
|
412
|
+
);
|
|
413
|
+
if (!codeEditor) {
|
|
414
|
+
decoratorMap.deleteAndDispose(editorId);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (decoratorMap.size === 0) {
|
|
418
|
+
decoratorMap.dispose();
|
|
419
|
+
this.decorators.delete(uri);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
dispose() {
|
|
424
|
+
this.disable();
|
|
425
|
+
super.dispose();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
QuickDiffWorkbenchController = ( __decorate([( __param(0, IEditorService)), ( __param(1, IConfigurationService)), ( __param(2, IQuickDiffModelService)), ( __param(3, IQuickDiffService)), ( __param(4, IUriIdentityService)), ( __param(5, IContextKeyService))], QuickDiffWorkbenchController));
|
|
429
|
+
|
|
430
|
+
export { QuickDiffWorkbenchController, quickDiffDecorationCount };
|
|
@@ -211,6 +211,9 @@ let QuickDiffModel = class QuickDiffModel extends Disposable {
|
|
|
211
211
|
location,
|
|
212
212
|
delay: 250
|
|
213
213
|
}, async () => {
|
|
214
|
+
if (this._disposed || this._model.isDisposed()) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
214
217
|
const versionId = this._model.textEditorModel.getVersionId();
|
|
215
218
|
const originalURIs = await this.getQuickDiffsPromise();
|
|
216
219
|
if (this._disposed || this._model.isDisposed() || (originalURIs.length === 0)) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Action, IAction } from "@codingame/monaco-vscode-api/vscode/vs/base/common/actions";
|
|
2
|
+
import { IContextViewService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service";
|
|
3
|
+
import { ISelectOptionItem } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/selectBox/selectBox";
|
|
4
|
+
import { SelectActionViewItem } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems";
|
|
5
|
+
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
|
6
|
+
import { ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
|
7
|
+
import { EditorAction } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions";
|
|
8
|
+
import { IInstantiationService, ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
9
|
+
import { IEditorContribution } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/editorCommon";
|
|
10
|
+
import { IQuickDiffModelService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/browser/quickDiffModel.service";
|
|
11
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
12
|
+
import { RawContextKey } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
|
|
13
|
+
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
14
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
15
|
+
import { QuickDiff } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff";
|
|
16
|
+
export declare const isQuickDiffVisible: RawContextKey<boolean>;
|
|
17
|
+
export interface IQuickDiffSelectItem extends ISelectOptionItem {
|
|
18
|
+
providerId: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class QuickDiffPickerViewItem extends SelectActionViewItem<IQuickDiffSelectItem> {
|
|
21
|
+
private optionsItems;
|
|
22
|
+
constructor(action: IAction, contextViewService: IContextViewService, themeService: IThemeService, configurationService: IConfigurationService);
|
|
23
|
+
setSelection(quickDiffs: QuickDiff[], providerId: string): void;
|
|
24
|
+
protected getActionContext(_: string, index: number): IQuickDiffSelectItem;
|
|
25
|
+
render(container: HTMLElement): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class QuickDiffPickerBaseAction extends Action {
|
|
28
|
+
private readonly callback;
|
|
29
|
+
static readonly ID = "quickDiff.base.switch";
|
|
30
|
+
static readonly LABEL: string;
|
|
31
|
+
constructor(callback: (event?: IQuickDiffSelectItem) => void);
|
|
32
|
+
run(event?: IQuickDiffSelectItem): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare class QuickDiffEditorController extends Disposable implements IEditorContribution {
|
|
35
|
+
private editor;
|
|
36
|
+
private readonly configurationService;
|
|
37
|
+
private readonly quickDiffModelService;
|
|
38
|
+
private readonly instantiationService;
|
|
39
|
+
static readonly ID = "editor.contrib.quickdiff";
|
|
40
|
+
static get(editor: ICodeEditor): QuickDiffEditorController | null;
|
|
41
|
+
private model;
|
|
42
|
+
private widget;
|
|
43
|
+
private readonly isQuickDiffVisible;
|
|
44
|
+
private session;
|
|
45
|
+
private mouseDownInfo;
|
|
46
|
+
private enabled;
|
|
47
|
+
private readonly gutterActionDisposables;
|
|
48
|
+
private stylesheet;
|
|
49
|
+
constructor(editor: ICodeEditor, contextKeyService: IContextKeyService, configurationService: IConfigurationService, quickDiffModelService: IQuickDiffModelService, instantiationService: IInstantiationService);
|
|
50
|
+
private onDidChangeGutterAction;
|
|
51
|
+
canNavigate(): boolean;
|
|
52
|
+
refresh(): void;
|
|
53
|
+
toggleFocus(): void;
|
|
54
|
+
next(lineNumber?: number): void;
|
|
55
|
+
previous(lineNumber?: number): void;
|
|
56
|
+
close(): void;
|
|
57
|
+
private assertWidget;
|
|
58
|
+
private onDidModelChange;
|
|
59
|
+
private onEditorMouseDown;
|
|
60
|
+
private onEditorMouseUp;
|
|
61
|
+
dispose(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare class ShowPreviousChangeAction extends EditorAction {
|
|
64
|
+
private readonly outerEditor?;
|
|
65
|
+
constructor(outerEditor?: ICodeEditor | undefined);
|
|
66
|
+
run(accessor: ServicesAccessor): void;
|
|
67
|
+
}
|
|
68
|
+
export declare class ShowNextChangeAction extends EditorAction {
|
|
69
|
+
private readonly outerEditor?;
|
|
70
|
+
constructor(outerEditor?: ICodeEditor | undefined);
|
|
71
|
+
run(accessor: ServicesAccessor): void;
|
|
72
|
+
}
|
|
73
|
+
export declare class GotoPreviousChangeAction extends EditorAction {
|
|
74
|
+
constructor();
|
|
75
|
+
run(accessor: ServicesAccessor): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export declare class GotoNextChangeAction extends EditorAction {
|
|
78
|
+
constructor();
|
|
79
|
+
run(accessor: ServicesAccessor): Promise<void>;
|
|
80
|
+
}
|