@codingame/monaco-vscode-scm-service-override 31.0.0 → 32.0.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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/activity.js +5 -5
- package/vscode/src/vs/workbench/contrib/scm/browser/menus.js +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/scm.contribution.js +77 -96
- 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 +19 -19
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewService.js +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/media/dirtydiffDecorator.css +0 -173
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffDecorator.d.ts +0 -36
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffDecorator.js +0 -430
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffWidget.d.ts +0 -80
- package/vscode/src/vs/workbench/contrib/scm/browser/quickDiffWidget.js +0 -933
|
@@ -1,933 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
4
|
-
import { prepend, $ } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
5
|
-
import { createStyleSheet } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
|
|
6
|
-
import { Action, ActionRunner } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
7
|
-
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
8
|
-
import { IContextViewService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
|
|
9
|
-
import { SelectActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems';
|
|
10
|
-
import { defaultSelectBoxStyles } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/browser/defaultStyles';
|
|
11
|
-
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
12
|
-
import { peekViewTitleBackground, PeekViewWidget, peekViewBorder, peekViewTitleInfoForeground, peekViewTitleForeground } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/peekView/browser/peekView';
|
|
13
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
|
|
14
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
|
|
15
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
16
|
-
import { editorBackground } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
|
|
17
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
|
|
18
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
|
|
19
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
|
|
20
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
21
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
|
|
22
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
23
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
|
|
24
|
-
import { MenuItemAction, MenuId, MenuRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
25
|
-
import { IMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions.service';
|
|
26
|
-
import { MouseTargetType } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
|
|
27
|
-
import { EditorAction, registerEditorAction } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
|
|
28
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
29
|
-
import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
30
|
-
import { EmbeddedDiffEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/embeddedDiffEditorWidget';
|
|
31
|
-
import { ScrollType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorCommon';
|
|
32
|
-
import { IQuickDiffModelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/browser/quickDiffModel.service';
|
|
33
|
-
import { Disposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
34
|
-
import { RawContextKey, ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
35
|
-
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
36
|
-
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
37
|
-
import { rot } from '@codingame/monaco-vscode-api/vscode/vs/base/common/numbers';
|
|
38
|
-
import { getModifiedEndLineNumber, getChangeHeight, getChangeType, getChangeTypeColor, lineIntersectsChange, ChangeType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff';
|
|
39
|
-
import { IQuickDiffService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff.service';
|
|
40
|
-
import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service';
|
|
41
|
-
import { TextCompareEditorActiveContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
42
|
-
import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
|
|
43
|
-
import { KeybindingWeight, KeybindingsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
44
|
-
import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
45
|
-
import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
46
|
-
import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
47
|
-
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
48
|
-
import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
49
|
-
import { EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
|
|
50
|
-
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
51
|
-
import { getFlatActionBarActions } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
52
|
-
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
53
|
-
import { gotoPreviousLocation, gotoNextLocation } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/iconRegistry';
|
|
54
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
55
|
-
import { Color } from '@codingame/monaco-vscode-api/vscode/vs/base/common/color';
|
|
56
|
-
import { KeyMod, KeyCode, KeyChord } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
57
|
-
import { getOuterEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
|
|
58
|
-
import { quickDiffDecorationCount } from './quickDiffDecorator.js';
|
|
59
|
-
import { hasNativeContextMenu } from '@codingame/monaco-vscode-api/vscode/vs/platform/window/common/window';
|
|
60
|
-
|
|
61
|
-
var QuickDiffEditorController_1;
|
|
62
|
-
const isQuickDiffVisible = ( new RawContextKey("dirtyDiffVisible", false));
|
|
63
|
-
let QuickDiffPickerViewItem = class QuickDiffPickerViewItem extends SelectActionViewItem {
|
|
64
|
-
constructor(action, contextViewService, themeService, configurationService) {
|
|
65
|
-
const styles = {
|
|
66
|
-
...defaultSelectBoxStyles
|
|
67
|
-
};
|
|
68
|
-
const theme = themeService.getColorTheme();
|
|
69
|
-
const editorBackgroundColor = theme.getColor(editorBackground);
|
|
70
|
-
const peekTitleColor = theme.getColor(peekViewTitleBackground);
|
|
71
|
-
const opaqueTitleColor = peekTitleColor?.makeOpaque(editorBackgroundColor) ?? editorBackgroundColor;
|
|
72
|
-
styles.selectBackground = ( ( opaqueTitleColor.lighten(.6)).toString());
|
|
73
|
-
super(null, action, [], 0, contextViewService, styles, {
|
|
74
|
-
ariaLabel: ( localize(12352, "Switch quick diff base")),
|
|
75
|
-
useCustomDrawn: !hasNativeContextMenu(configurationService)
|
|
76
|
-
});
|
|
77
|
-
this.optionsItems = [];
|
|
78
|
-
}
|
|
79
|
-
setSelection(quickDiffs, providerId) {
|
|
80
|
-
this.optionsItems = ( quickDiffs.map(quickDiff => ({
|
|
81
|
-
providerId: quickDiff.id,
|
|
82
|
-
text: quickDiff.label
|
|
83
|
-
})));
|
|
84
|
-
const index = this.optionsItems.findIndex(item => item.providerId === providerId);
|
|
85
|
-
this.setOptions(this.optionsItems, index);
|
|
86
|
-
}
|
|
87
|
-
getActionContext(_, index) {
|
|
88
|
-
return this.optionsItems[index];
|
|
89
|
-
}
|
|
90
|
-
render(container) {
|
|
91
|
-
super.render(container);
|
|
92
|
-
this.setFocusable(true);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
QuickDiffPickerViewItem = ( __decorate([( __param(1, IContextViewService)), ( __param(2, IThemeService)), ( __param(3, IConfigurationService))], QuickDiffPickerViewItem));
|
|
96
|
-
class QuickDiffPickerBaseAction extends Action {
|
|
97
|
-
static {
|
|
98
|
-
this.ID = "quickDiff.base.switch";
|
|
99
|
-
}
|
|
100
|
-
static {
|
|
101
|
-
this.LABEL = ( localize(12353, "Switch Quick Diff Base"));
|
|
102
|
-
}
|
|
103
|
-
constructor(callback) {
|
|
104
|
-
super(
|
|
105
|
-
QuickDiffPickerBaseAction.ID,
|
|
106
|
-
QuickDiffPickerBaseAction.LABEL,
|
|
107
|
-
undefined,
|
|
108
|
-
undefined
|
|
109
|
-
);
|
|
110
|
-
this.callback = callback;
|
|
111
|
-
}
|
|
112
|
-
async run(event) {
|
|
113
|
-
return this.callback(event);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
class QuickDiffWidgetActionRunner extends ActionRunner {
|
|
117
|
-
runAction(action, context) {
|
|
118
|
-
if (action instanceof MenuItemAction) {
|
|
119
|
-
return action.run(...context);
|
|
120
|
-
}
|
|
121
|
-
return super.runAction(action, context);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let QuickDiffWidgetEditorAction = class QuickDiffWidgetEditorAction extends Action {
|
|
125
|
-
constructor(editor, action, cssClass, keybindingService, instantiationService) {
|
|
126
|
-
const label = keybindingService.appendKeybinding(action.label, action.id);
|
|
127
|
-
super(action.id, label, cssClass);
|
|
128
|
-
this.instantiationService = instantiationService;
|
|
129
|
-
this.action = action;
|
|
130
|
-
this.editor = editor;
|
|
131
|
-
}
|
|
132
|
-
run() {
|
|
133
|
-
return Promise.resolve(
|
|
134
|
-
this.instantiationService.invokeFunction(accessor => this.action.run(accessor, this.editor, null))
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
QuickDiffWidgetEditorAction = ( __decorate([( __param(3, IKeybindingService)), ( __param(4, IInstantiationService))], QuickDiffWidgetEditorAction));
|
|
139
|
-
let QuickDiffWidget = class QuickDiffWidget extends PeekViewWidget {
|
|
140
|
-
constructor(
|
|
141
|
-
editor,
|
|
142
|
-
model,
|
|
143
|
-
themeService,
|
|
144
|
-
instantiationService,
|
|
145
|
-
menuService,
|
|
146
|
-
contextKeyService,
|
|
147
|
-
quickDiffService
|
|
148
|
-
) {
|
|
149
|
-
super(editor, {
|
|
150
|
-
isResizeable: true,
|
|
151
|
-
frameWidth: 1,
|
|
152
|
-
keepEditorSelection: true,
|
|
153
|
-
className: "dirty-diff"
|
|
154
|
-
}, instantiationService);
|
|
155
|
-
this.model = model;
|
|
156
|
-
this.themeService = themeService;
|
|
157
|
-
this.menuService = menuService;
|
|
158
|
-
this.contextKeyService = contextKeyService;
|
|
159
|
-
this.quickDiffService = quickDiffService;
|
|
160
|
-
this._index = 0;
|
|
161
|
-
this._providerId = "";
|
|
162
|
-
this.height = undefined;
|
|
163
|
-
this._disposables.add(themeService.onDidColorThemeChange(this._applyTheme, this));
|
|
164
|
-
this._applyTheme(themeService.getColorTheme());
|
|
165
|
-
if (!Iterable.isEmpty(this.model.originalTextModels)) {
|
|
166
|
-
contextKeyService = contextKeyService.createOverlay([[
|
|
167
|
-
"originalResourceScheme",
|
|
168
|
-
Iterable.first(this.model.originalTextModels)?.uri.scheme
|
|
169
|
-
], ["originalResourceSchemes", ( Iterable.map(this.model.originalTextModels, textModel => textModel.uri.scheme))]]);
|
|
170
|
-
}
|
|
171
|
-
this.create();
|
|
172
|
-
if (editor.hasModel()) {
|
|
173
|
-
this.title = basename(editor.getModel().uri);
|
|
174
|
-
} else {
|
|
175
|
-
this.title = "";
|
|
176
|
-
}
|
|
177
|
-
this.setTitle(this.title);
|
|
178
|
-
}
|
|
179
|
-
get providerId() {
|
|
180
|
-
return this._providerId;
|
|
181
|
-
}
|
|
182
|
-
get index() {
|
|
183
|
-
return this._index;
|
|
184
|
-
}
|
|
185
|
-
get visibleRange() {
|
|
186
|
-
const visibleRanges = this.diffEditor.getModifiedEditor().getVisibleRanges();
|
|
187
|
-
return visibleRanges.length >= 0 ? visibleRanges[0] : undefined;
|
|
188
|
-
}
|
|
189
|
-
showChange(index, usePosition = true) {
|
|
190
|
-
const labeledChange = this.model.changes[index];
|
|
191
|
-
const change = labeledChange.change;
|
|
192
|
-
this._index = index;
|
|
193
|
-
this.contextKeyService.createKey("originalResource", ( this.model.changes[index].original.toString()));
|
|
194
|
-
this.contextKeyService.createKey("originalResourceScheme", this.model.changes[index].original.scheme);
|
|
195
|
-
this.updateActions();
|
|
196
|
-
this.change = change;
|
|
197
|
-
this._providerId = labeledChange.providerId;
|
|
198
|
-
if (Iterable.isEmpty(this.model.originalTextModels)) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const onFirstDiffUpdate = Event.once(this.diffEditor.onDidUpdateDiff);
|
|
202
|
-
onFirstDiffUpdate(() => setTimeout(() => this.revealChange(change), 0));
|
|
203
|
-
const diffEditorModel = this.model.getDiffEditorModel(labeledChange.original);
|
|
204
|
-
if (!diffEditorModel) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
this.diffEditor.setModel(diffEditorModel);
|
|
208
|
-
const position = ( new Position(getModifiedEndLineNumber(change), 1));
|
|
209
|
-
const lineHeight = this.editor.getOption(EditorOption.lineHeight);
|
|
210
|
-
const editorHeight = this.editor.getLayoutInfo().height;
|
|
211
|
-
const editorHeightInLines = Math.floor(editorHeight / lineHeight);
|
|
212
|
-
const height = Math.min(
|
|
213
|
-
getChangeHeight(change) + 2 + 6,
|
|
214
|
-
Math.floor(editorHeightInLines / 3)
|
|
215
|
-
);
|
|
216
|
-
this.renderTitle();
|
|
217
|
-
this.updateDropdown();
|
|
218
|
-
const changeType = getChangeType(change);
|
|
219
|
-
const changeTypeColor = getChangeTypeColor(this.themeService.getColorTheme(), changeType);
|
|
220
|
-
this.style({
|
|
221
|
-
frameColor: changeTypeColor,
|
|
222
|
-
arrowColor: changeTypeColor
|
|
223
|
-
});
|
|
224
|
-
const providerSpecificChanges = [];
|
|
225
|
-
let contextIndex = index;
|
|
226
|
-
for (const change of this.model.changes) {
|
|
227
|
-
if (change.providerId === this.model.changes[this._index].providerId) {
|
|
228
|
-
providerSpecificChanges.push(change.change);
|
|
229
|
-
if (labeledChange === change) {
|
|
230
|
-
contextIndex = providerSpecificChanges.length - 1;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
this._actionbarWidget.context = [diffEditorModel.modified.uri, providerSpecificChanges, contextIndex];
|
|
235
|
-
if (usePosition) {
|
|
236
|
-
this.show(position, height + (1 / lineHeight));
|
|
237
|
-
this.editor.setPosition(position);
|
|
238
|
-
this.editor.focus();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
renderTitle() {
|
|
242
|
-
const providerChanges = this.model.quickDiffChanges.get(this._providerId);
|
|
243
|
-
const providerIndex = providerChanges.indexOf(this._index);
|
|
244
|
-
let detail;
|
|
245
|
-
if (!this.shouldUseDropdown()) {
|
|
246
|
-
const label = this.model.quickDiffs.find(quickDiff => quickDiff.id === this._providerId)?.label ?? "";
|
|
247
|
-
detail = this.model.changes.length > 1 ? ( localize(
|
|
248
|
-
12354,
|
|
249
|
-
"{0} - {1} of {2} changes",
|
|
250
|
-
label,
|
|
251
|
-
providerIndex + 1,
|
|
252
|
-
providerChanges.length
|
|
253
|
-
)) : ( localize(
|
|
254
|
-
12355,
|
|
255
|
-
"{0} - {1} of {2} change",
|
|
256
|
-
label,
|
|
257
|
-
providerIndex + 1,
|
|
258
|
-
providerChanges.length
|
|
259
|
-
));
|
|
260
|
-
this.dropdownContainer.style.display = "none";
|
|
261
|
-
} else {
|
|
262
|
-
detail = this.model.changes.length > 1 ? ( localize(12356, "{0} of {1} changes", providerIndex + 1, providerChanges.length)) : ( localize(12357, "{0} of {1} change", providerIndex + 1, providerChanges.length));
|
|
263
|
-
this.dropdownContainer.style.display = "inherit";
|
|
264
|
-
}
|
|
265
|
-
this.setTitle(this.title, detail);
|
|
266
|
-
}
|
|
267
|
-
switchQuickDiff(event) {
|
|
268
|
-
const newProviderId = event?.providerId;
|
|
269
|
-
if (newProviderId === this.model.changes[this._index].providerId) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
let closestGreaterIndex = this._index < this.model.changes.length - 1 ? this._index + 1 : 0;
|
|
273
|
-
for (let i = closestGreaterIndex; i !== this._index; i < this.model.changes.length - 1 ? i++ : i = 0) {
|
|
274
|
-
if (this.model.changes[i].providerId === newProviderId) {
|
|
275
|
-
closestGreaterIndex = i;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
let closestLesserIndex = this._index > 0 ? this._index - 1 : this.model.changes.length - 1;
|
|
280
|
-
for (let i = closestLesserIndex; i !== this._index; i > 0 ? i-- : i = this.model.changes.length - 1) {
|
|
281
|
-
if (this.model.changes[i].providerId === newProviderId) {
|
|
282
|
-
closestLesserIndex = i;
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const closestIndex = Math.abs(
|
|
287
|
-
this.model.changes[closestGreaterIndex].change.modifiedEndLineNumber - this.model.changes[this._index].change.modifiedEndLineNumber
|
|
288
|
-
) < Math.abs(
|
|
289
|
-
this.model.changes[closestLesserIndex].change.modifiedEndLineNumber - this.model.changes[this._index].change.modifiedEndLineNumber
|
|
290
|
-
) ? closestGreaterIndex : closestLesserIndex;
|
|
291
|
-
this.showChange(closestIndex, false);
|
|
292
|
-
}
|
|
293
|
-
shouldUseDropdown() {
|
|
294
|
-
const quickDiffs = this.getQuickDiffsContainingChange();
|
|
295
|
-
return quickDiffs.length > 1;
|
|
296
|
-
}
|
|
297
|
-
updateActions() {
|
|
298
|
-
if (!this._actionbarWidget) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
const previous = this.instantiationService.createInstance(QuickDiffWidgetEditorAction, this.editor, ( new ShowPreviousChangeAction(this.editor)), ThemeIcon.asClassName(gotoPreviousLocation));
|
|
302
|
-
const next = this.instantiationService.createInstance(QuickDiffWidgetEditorAction, this.editor, ( new ShowNextChangeAction(this.editor)), ThemeIcon.asClassName(gotoNextLocation));
|
|
303
|
-
this._disposables.add(previous);
|
|
304
|
-
this._disposables.add(next);
|
|
305
|
-
if (this.menu) {
|
|
306
|
-
this.menu.dispose();
|
|
307
|
-
}
|
|
308
|
-
this.menu = this.menuService.createMenu(MenuId.SCMChangeContext, this.contextKeyService);
|
|
309
|
-
const actions = getFlatActionBarActions(this.menu.getActions({
|
|
310
|
-
shouldForwardArgs: true
|
|
311
|
-
}));
|
|
312
|
-
this._actionbarWidget.clear();
|
|
313
|
-
this._actionbarWidget.push(actions.reverse(), {
|
|
314
|
-
label: false,
|
|
315
|
-
icon: true
|
|
316
|
-
});
|
|
317
|
-
this._actionbarWidget.push([next, previous], {
|
|
318
|
-
label: false,
|
|
319
|
-
icon: true
|
|
320
|
-
});
|
|
321
|
-
this._actionbarWidget.push(this._disposables.add(( new Action("peekview.close", ( localize(12358, "Close")), ThemeIcon.asClassName(Codicon.close), true, () => this.dispose()))), {
|
|
322
|
-
label: false,
|
|
323
|
-
icon: true
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
updateDropdown() {
|
|
327
|
-
const quickDiffs = this.getQuickDiffsContainingChange();
|
|
328
|
-
this.dropdown?.setSelection(quickDiffs, this._providerId);
|
|
329
|
-
}
|
|
330
|
-
getQuickDiffsContainingChange() {
|
|
331
|
-
const change = this.model.changes[this._index];
|
|
332
|
-
const quickDiffsWithChange = ( this.model.changes.filter(c => change.change2.modified.intersectsOrTouches(c.change2.modified)).map(c => c.providerId));
|
|
333
|
-
return this.model.quickDiffs.filter(
|
|
334
|
-
quickDiff => quickDiffsWithChange.includes(quickDiff.id) && this.quickDiffService.isQuickDiffProviderVisible(quickDiff.id)
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
_fillHead(container) {
|
|
338
|
-
super._fillHead(container, true);
|
|
339
|
-
const action = ( new QuickDiffPickerBaseAction(event => this.switchQuickDiff(event)));
|
|
340
|
-
this._disposables.add(action);
|
|
341
|
-
this.dropdownContainer = prepend(this._titleElement, $(".dropdown"));
|
|
342
|
-
this.dropdown = this.instantiationService.createInstance(QuickDiffPickerViewItem, action);
|
|
343
|
-
this.dropdown.render(this.dropdownContainer);
|
|
344
|
-
}
|
|
345
|
-
_getActionBarOptions() {
|
|
346
|
-
const actionRunner = ( new QuickDiffWidgetActionRunner());
|
|
347
|
-
this._disposables.add(actionRunner);
|
|
348
|
-
this._disposables.add(actionRunner.onDidRun(e => {
|
|
349
|
-
if (!(e.action instanceof QuickDiffWidgetEditorAction) && !e.error) {
|
|
350
|
-
this.dispose();
|
|
351
|
-
}
|
|
352
|
-
}));
|
|
353
|
-
return {
|
|
354
|
-
...super._getActionBarOptions(),
|
|
355
|
-
actionRunner
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
_fillBody(container) {
|
|
359
|
-
const options = {
|
|
360
|
-
diffAlgorithm: "advanced",
|
|
361
|
-
fixedOverflowWidgets: true,
|
|
362
|
-
ignoreTrimWhitespace: false,
|
|
363
|
-
minimap: {
|
|
364
|
-
enabled: false
|
|
365
|
-
},
|
|
366
|
-
readOnly: false,
|
|
367
|
-
renderGutterMenu: false,
|
|
368
|
-
renderIndicators: false,
|
|
369
|
-
renderOverviewRuler: false,
|
|
370
|
-
renderSideBySide: false,
|
|
371
|
-
scrollbar: {
|
|
372
|
-
verticalScrollbarSize: 14,
|
|
373
|
-
horizontal: "auto",
|
|
374
|
-
useShadows: true,
|
|
375
|
-
verticalHasArrows: false,
|
|
376
|
-
horizontalHasArrows: false
|
|
377
|
-
},
|
|
378
|
-
scrollBeyondLastLine: false,
|
|
379
|
-
stickyScroll: {
|
|
380
|
-
enabled: false
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
this.diffEditor = this.instantiationService.createInstance(EmbeddedDiffEditorWidget, container, options, {}, this.editor);
|
|
384
|
-
this._disposables.add(this.diffEditor);
|
|
385
|
-
}
|
|
386
|
-
_onWidth(width) {
|
|
387
|
-
if (typeof this.height === "undefined") {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
this.diffEditor.layout({
|
|
391
|
-
height: this.height,
|
|
392
|
-
width
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
_doLayoutBody(height, width) {
|
|
396
|
-
super._doLayoutBody(height, width);
|
|
397
|
-
this.diffEditor.layout({
|
|
398
|
-
height,
|
|
399
|
-
width
|
|
400
|
-
});
|
|
401
|
-
if (typeof this.height === "undefined" && this.change) {
|
|
402
|
-
this.revealChange(this.change);
|
|
403
|
-
}
|
|
404
|
-
this.height = height;
|
|
405
|
-
}
|
|
406
|
-
revealChange(change) {
|
|
407
|
-
let start, end;
|
|
408
|
-
if (change.modifiedEndLineNumber === 0) {
|
|
409
|
-
start = change.modifiedStartLineNumber;
|
|
410
|
-
end = change.modifiedStartLineNumber + 1;
|
|
411
|
-
} else if (change.originalEndLineNumber > 0) {
|
|
412
|
-
start = change.modifiedStartLineNumber - 1;
|
|
413
|
-
end = change.modifiedEndLineNumber + 1;
|
|
414
|
-
} else {
|
|
415
|
-
start = change.modifiedStartLineNumber;
|
|
416
|
-
end = change.modifiedEndLineNumber;
|
|
417
|
-
}
|
|
418
|
-
this.diffEditor.revealLinesInCenter(start, end, ScrollType.Immediate);
|
|
419
|
-
}
|
|
420
|
-
_applyTheme(theme) {
|
|
421
|
-
const borderColor = theme.getColor(peekViewBorder) || Color.transparent;
|
|
422
|
-
this.style({
|
|
423
|
-
arrowColor: borderColor,
|
|
424
|
-
frameColor: borderColor,
|
|
425
|
-
headerBackgroundColor: theme.getColor(peekViewTitleBackground) || Color.transparent,
|
|
426
|
-
primaryHeadingColor: theme.getColor(peekViewTitleForeground),
|
|
427
|
-
secondaryHeadingColor: theme.getColor(peekViewTitleInfoForeground)
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
revealRange(range) {
|
|
431
|
-
this.editor.revealLineInCenterIfOutsideViewport(range.endLineNumber, ScrollType.Smooth);
|
|
432
|
-
}
|
|
433
|
-
hasFocus() {
|
|
434
|
-
return this.diffEditor.hasTextFocus();
|
|
435
|
-
}
|
|
436
|
-
toggleFocus() {
|
|
437
|
-
if (this.diffEditor.hasTextFocus()) {
|
|
438
|
-
this.editor.focus();
|
|
439
|
-
} else {
|
|
440
|
-
this.diffEditor.focus();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
dispose() {
|
|
444
|
-
this.dropdown?.dispose();
|
|
445
|
-
this.menu?.dispose();
|
|
446
|
-
super.dispose();
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
QuickDiffWidget = ( __decorate([( __param(2, IThemeService)), ( __param(3, IInstantiationService)), ( __param(4, IMenuService)), ( __param(5, IContextKeyService)), ( __param(6, IQuickDiffService))], QuickDiffWidget));
|
|
450
|
-
let QuickDiffEditorController = class QuickDiffEditorController extends Disposable {
|
|
451
|
-
static {
|
|
452
|
-
QuickDiffEditorController_1 = this;
|
|
453
|
-
}
|
|
454
|
-
static {
|
|
455
|
-
this.ID = "editor.contrib.quickdiff";
|
|
456
|
-
}
|
|
457
|
-
static get(editor) {
|
|
458
|
-
return editor.getContribution(QuickDiffEditorController_1.ID);
|
|
459
|
-
}
|
|
460
|
-
constructor(
|
|
461
|
-
editor,
|
|
462
|
-
contextKeyService,
|
|
463
|
-
configurationService,
|
|
464
|
-
quickDiffModelService,
|
|
465
|
-
instantiationService
|
|
466
|
-
) {
|
|
467
|
-
super();
|
|
468
|
-
this.editor = editor;
|
|
469
|
-
this.configurationService = configurationService;
|
|
470
|
-
this.quickDiffModelService = quickDiffModelService;
|
|
471
|
-
this.instantiationService = instantiationService;
|
|
472
|
-
this.model = null;
|
|
473
|
-
this.widget = null;
|
|
474
|
-
this.session = Disposable.None;
|
|
475
|
-
this.mouseDownInfo = null;
|
|
476
|
-
this.enabled = false;
|
|
477
|
-
this.gutterActionDisposables = ( new DisposableStore());
|
|
478
|
-
this.enabled = !contextKeyService.getContextKeyValue("isInDiffEditor");
|
|
479
|
-
this.stylesheet = createStyleSheet(undefined, undefined, this._store);
|
|
480
|
-
if (this.enabled) {
|
|
481
|
-
this.isQuickDiffVisible = isQuickDiffVisible.bindTo(contextKeyService);
|
|
482
|
-
this._register(editor.onDidChangeModel(() => this.close()));
|
|
483
|
-
const onDidChangeGutterAction = Event.filter(
|
|
484
|
-
configurationService.onDidChangeConfiguration,
|
|
485
|
-
e => e.affectsConfiguration("scm.diffDecorationsGutterAction")
|
|
486
|
-
);
|
|
487
|
-
this._register(onDidChangeGutterAction(this.onDidChangeGutterAction, this));
|
|
488
|
-
this.onDidChangeGutterAction();
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
onDidChangeGutterAction() {
|
|
492
|
-
const gutterAction = this.configurationService.getValue("scm.diffDecorationsGutterAction");
|
|
493
|
-
this.gutterActionDisposables.clear();
|
|
494
|
-
if (gutterAction === "diff") {
|
|
495
|
-
this.gutterActionDisposables.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
|
|
496
|
-
this.gutterActionDisposables.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
|
|
497
|
-
this.stylesheet.textContent = `
|
|
498
|
-
.monaco-editor .dirty-diff-glyph {
|
|
499
|
-
cursor: pointer;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
.monaco-editor .margin-view-overlays .dirty-diff-glyph:hover::before {
|
|
503
|
-
height: 100%;
|
|
504
|
-
width: 6px;
|
|
505
|
-
left: -6px;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
.monaco-editor .margin-view-overlays .dirty-diff-deleted:hover::after {
|
|
509
|
-
bottom: 0;
|
|
510
|
-
border-top-width: 0;
|
|
511
|
-
border-bottom-width: 0;
|
|
512
|
-
}
|
|
513
|
-
`;
|
|
514
|
-
} else {
|
|
515
|
-
this.stylesheet.textContent = ``;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
canNavigate() {
|
|
519
|
-
return !this.widget || (this.widget?.index === -1) || (!!this.model && this.model.changes.length > 1);
|
|
520
|
-
}
|
|
521
|
-
refresh() {
|
|
522
|
-
this.widget?.showChange(this.widget.index, false);
|
|
523
|
-
}
|
|
524
|
-
toggleFocus() {
|
|
525
|
-
if (this.widget) {
|
|
526
|
-
this.widget.toggleFocus();
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
next(lineNumber) {
|
|
530
|
-
if (!this.assertWidget()) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
if (!this.widget || !this.model) {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
let index;
|
|
537
|
-
if (this.editor.hasModel() && (typeof lineNumber === "number" || !this.widget.providerId)) {
|
|
538
|
-
index = this.model.findNextClosestChange(
|
|
539
|
-
typeof lineNumber === "number" ? lineNumber : this.editor.getPosition().lineNumber,
|
|
540
|
-
true,
|
|
541
|
-
this.widget.providerId
|
|
542
|
-
);
|
|
543
|
-
} else {
|
|
544
|
-
const providerChanges = this.model.quickDiffChanges.get(this.widget.providerId) ?? ( this.model.quickDiffChanges.values()).next().value;
|
|
545
|
-
const mapIndex = providerChanges.findIndex(value => value === this.widget.index);
|
|
546
|
-
index = providerChanges[rot(mapIndex + 1, providerChanges.length)];
|
|
547
|
-
}
|
|
548
|
-
this.widget.showChange(index);
|
|
549
|
-
}
|
|
550
|
-
previous(lineNumber) {
|
|
551
|
-
if (!this.assertWidget()) {
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
if (!this.widget || !this.model) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
let index;
|
|
558
|
-
if (this.editor.hasModel() && (typeof lineNumber === "number" || !this.widget.providerId)) {
|
|
559
|
-
index = this.model.findPreviousClosestChange(
|
|
560
|
-
typeof lineNumber === "number" ? lineNumber : this.editor.getPosition().lineNumber,
|
|
561
|
-
true,
|
|
562
|
-
this.widget.providerId
|
|
563
|
-
);
|
|
564
|
-
} else {
|
|
565
|
-
const providerChanges = this.model.quickDiffChanges.get(this.widget.providerId) ?? ( this.model.quickDiffChanges.values()).next().value;
|
|
566
|
-
const mapIndex = providerChanges.findIndex(value => value === this.widget.index);
|
|
567
|
-
index = providerChanges[rot(mapIndex - 1, providerChanges.length)];
|
|
568
|
-
}
|
|
569
|
-
this.widget.showChange(index);
|
|
570
|
-
}
|
|
571
|
-
close() {
|
|
572
|
-
this.session.dispose();
|
|
573
|
-
this.session = Disposable.None;
|
|
574
|
-
}
|
|
575
|
-
assertWidget() {
|
|
576
|
-
if (!this.enabled) {
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
if (this.widget) {
|
|
580
|
-
if (!this.model || this.model.changes.length === 0) {
|
|
581
|
-
this.close();
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
return true;
|
|
585
|
-
}
|
|
586
|
-
const editorModel = this.editor.getModel();
|
|
587
|
-
if (!editorModel) {
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
const modelRef = this.quickDiffModelService.createQuickDiffModelReference(editorModel.uri);
|
|
591
|
-
if (!modelRef) {
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
if (modelRef.object.changes.length === 0) {
|
|
595
|
-
modelRef.dispose();
|
|
596
|
-
return false;
|
|
597
|
-
}
|
|
598
|
-
this.model = modelRef.object;
|
|
599
|
-
this.widget = this.instantiationService.createInstance(QuickDiffWidget, this.editor, this.model);
|
|
600
|
-
this.isQuickDiffVisible.set(true);
|
|
601
|
-
const disposables = ( new DisposableStore());
|
|
602
|
-
disposables.add(Event.once(this.widget.onDidClose)(this.close, this));
|
|
603
|
-
const onDidModelChange = Event.chain(this.model.onDidChange, $ => ( $.filter(e => e.diff.length > 0).map(e => e.diff)));
|
|
604
|
-
onDidModelChange(this.onDidModelChange, this, disposables);
|
|
605
|
-
disposables.add(modelRef);
|
|
606
|
-
disposables.add(this.widget);
|
|
607
|
-
disposables.add(toDisposable(() => {
|
|
608
|
-
this.model = null;
|
|
609
|
-
this.widget = null;
|
|
610
|
-
this.isQuickDiffVisible.set(false);
|
|
611
|
-
this.editor.focus();
|
|
612
|
-
}));
|
|
613
|
-
this.session = disposables;
|
|
614
|
-
return true;
|
|
615
|
-
}
|
|
616
|
-
onDidModelChange(splices) {
|
|
617
|
-
if (!this.model || !this.widget || this.widget.hasFocus()) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
for (const splice of splices) {
|
|
621
|
-
if (splice.start <= this.widget.index) {
|
|
622
|
-
this.next();
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
this.refresh();
|
|
627
|
-
}
|
|
628
|
-
onEditorMouseDown(e) {
|
|
629
|
-
this.mouseDownInfo = null;
|
|
630
|
-
const range = e.target.range;
|
|
631
|
-
if (!range) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
if (!e.event.leftButton) {
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
if (e.target.type !== MouseTargetType.GUTTER_LINE_DECORATIONS) {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
if (!e.target.element) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
if (e.target.element.className.indexOf("dirty-diff-glyph") < 0) {
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
const data = e.target.detail;
|
|
647
|
-
const offsetLeftInGutter = e.target.element.offsetLeft;
|
|
648
|
-
const gutterOffsetX = data.offsetX - offsetLeftInGutter;
|
|
649
|
-
if (gutterOffsetX < -3 || gutterOffsetX > 3) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
this.mouseDownInfo = {
|
|
653
|
-
lineNumber: range.startLineNumber
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
onEditorMouseUp(e) {
|
|
657
|
-
if (!this.mouseDownInfo) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
const {
|
|
661
|
-
lineNumber
|
|
662
|
-
} = this.mouseDownInfo;
|
|
663
|
-
this.mouseDownInfo = null;
|
|
664
|
-
const range = e.target.range;
|
|
665
|
-
if (!range || range.startLineNumber !== lineNumber) {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
if (e.target.type !== MouseTargetType.GUTTER_LINE_DECORATIONS) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
const editorModel = this.editor.getModel();
|
|
672
|
-
if (!editorModel) {
|
|
673
|
-
return;
|
|
674
|
-
}
|
|
675
|
-
const modelRef = this.quickDiffModelService.createQuickDiffModelReference(editorModel.uri);
|
|
676
|
-
if (!modelRef) {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
try {
|
|
680
|
-
const index = modelRef.object.changes.findIndex(change => lineIntersectsChange(lineNumber, change.change));
|
|
681
|
-
if (index < 0) {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
if (index === this.widget?.index) {
|
|
685
|
-
this.close();
|
|
686
|
-
} else {
|
|
687
|
-
this.next(lineNumber);
|
|
688
|
-
}
|
|
689
|
-
} finally {
|
|
690
|
-
modelRef.dispose();
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
dispose() {
|
|
694
|
-
this.gutterActionDisposables.dispose();
|
|
695
|
-
super.dispose();
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
QuickDiffEditorController = QuickDiffEditorController_1 = ( __decorate([( __param(1, IContextKeyService)), ( __param(2, IConfigurationService)), ( __param(3, IQuickDiffModelService)), ( __param(4, IInstantiationService))], QuickDiffEditorController));
|
|
699
|
-
class ShowPreviousChangeAction extends EditorAction {
|
|
700
|
-
constructor(outerEditor) {
|
|
701
|
-
super({
|
|
702
|
-
id: "editor.action.dirtydiff.previous",
|
|
703
|
-
label: ( localize2(12359, "Show Previous Change")),
|
|
704
|
-
precondition: ( TextCompareEditorActiveContext.toNegated()),
|
|
705
|
-
kbOpts: {
|
|
706
|
-
kbExpr: EditorContextKeys.editorTextFocus,
|
|
707
|
-
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F3,
|
|
708
|
-
weight: KeybindingWeight.EditorContrib
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
this.outerEditor = outerEditor;
|
|
712
|
-
}
|
|
713
|
-
run(accessor) {
|
|
714
|
-
const outerEditor = this.outerEditor ?? getOuterEditorFromDiffEditor(accessor);
|
|
715
|
-
if (!outerEditor) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
const controller = QuickDiffEditorController.get(outerEditor);
|
|
719
|
-
if (!controller) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
if (!controller.canNavigate()) {
|
|
723
|
-
return;
|
|
724
|
-
}
|
|
725
|
-
controller.previous();
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
registerEditorAction(ShowPreviousChangeAction);
|
|
729
|
-
class ShowNextChangeAction extends EditorAction {
|
|
730
|
-
constructor(outerEditor) {
|
|
731
|
-
super({
|
|
732
|
-
id: "editor.action.dirtydiff.next",
|
|
733
|
-
label: ( localize2(12360, "Show Next Change")),
|
|
734
|
-
precondition: ( TextCompareEditorActiveContext.toNegated()),
|
|
735
|
-
kbOpts: {
|
|
736
|
-
kbExpr: EditorContextKeys.editorTextFocus,
|
|
737
|
-
primary: KeyMod.Alt | KeyCode.F3,
|
|
738
|
-
weight: KeybindingWeight.EditorContrib
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
this.outerEditor = outerEditor;
|
|
742
|
-
}
|
|
743
|
-
run(accessor) {
|
|
744
|
-
const outerEditor = this.outerEditor ?? getOuterEditorFromDiffEditor(accessor);
|
|
745
|
-
if (!outerEditor) {
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
const controller = QuickDiffEditorController.get(outerEditor);
|
|
749
|
-
if (!controller) {
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
if (!controller.canNavigate()) {
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
controller.next();
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
registerEditorAction(ShowNextChangeAction);
|
|
759
|
-
class GotoPreviousChangeAction extends EditorAction {
|
|
760
|
-
constructor() {
|
|
761
|
-
super({
|
|
762
|
-
id: "workbench.action.editor.previousChange",
|
|
763
|
-
label: ( localize2(12361, "Go to Previous Change")),
|
|
764
|
-
precondition: ( ContextKeyExpr.and(( TextCompareEditorActiveContext.toNegated()), ( quickDiffDecorationCount.notEqualsTo(0)))),
|
|
765
|
-
kbOpts: {
|
|
766
|
-
kbExpr: EditorContextKeys.editorTextFocus,
|
|
767
|
-
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F5,
|
|
768
|
-
weight: KeybindingWeight.EditorContrib
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
async run(accessor) {
|
|
773
|
-
const outerEditor = getOuterEditorFromDiffEditor(accessor);
|
|
774
|
-
const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
|
|
775
|
-
const accessibilityService = accessor.get(IAccessibilityService);
|
|
776
|
-
const codeEditorService = accessor.get(ICodeEditorService);
|
|
777
|
-
const quickDiffModelService = accessor.get(IQuickDiffModelService);
|
|
778
|
-
if (!outerEditor || !outerEditor.hasModel()) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
const modelRef = quickDiffModelService.createQuickDiffModelReference(outerEditor.getModel().uri);
|
|
782
|
-
try {
|
|
783
|
-
if (!modelRef || modelRef.object.changes.length === 0) {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
const lineNumber = outerEditor.getPosition().lineNumber;
|
|
787
|
-
const index = modelRef.object.findPreviousClosestChange(lineNumber, false);
|
|
788
|
-
const change = modelRef.object.changes[index];
|
|
789
|
-
await playAccessibilitySymbolForChange(change.change, accessibilitySignalService);
|
|
790
|
-
setPositionAndSelection(change.change, outerEditor, accessibilityService, codeEditorService);
|
|
791
|
-
} finally {
|
|
792
|
-
modelRef?.dispose();
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
registerEditorAction(GotoPreviousChangeAction);
|
|
797
|
-
class GotoNextChangeAction extends EditorAction {
|
|
798
|
-
constructor() {
|
|
799
|
-
super({
|
|
800
|
-
id: "workbench.action.editor.nextChange",
|
|
801
|
-
label: ( localize2(12362, "Go to Next Change")),
|
|
802
|
-
precondition: ( ContextKeyExpr.and(( TextCompareEditorActiveContext.toNegated()), ( quickDiffDecorationCount.notEqualsTo(0)))),
|
|
803
|
-
kbOpts: {
|
|
804
|
-
kbExpr: EditorContextKeys.editorTextFocus,
|
|
805
|
-
primary: KeyMod.Alt | KeyCode.F5,
|
|
806
|
-
weight: KeybindingWeight.EditorContrib
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
async run(accessor) {
|
|
811
|
-
const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
|
|
812
|
-
const outerEditor = getOuterEditorFromDiffEditor(accessor);
|
|
813
|
-
const accessibilityService = accessor.get(IAccessibilityService);
|
|
814
|
-
const codeEditorService = accessor.get(ICodeEditorService);
|
|
815
|
-
const quickDiffModelService = accessor.get(IQuickDiffModelService);
|
|
816
|
-
if (!outerEditor || !outerEditor.hasModel()) {
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
const modelRef = quickDiffModelService.createQuickDiffModelReference(outerEditor.getModel().uri);
|
|
820
|
-
try {
|
|
821
|
-
if (!modelRef || modelRef.object.changes.length === 0) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
const lineNumber = outerEditor.getPosition().lineNumber;
|
|
825
|
-
const index = modelRef.object.findNextClosestChange(lineNumber, false);
|
|
826
|
-
const change = modelRef.object.changes[index].change;
|
|
827
|
-
await playAccessibilitySymbolForChange(change, accessibilitySignalService);
|
|
828
|
-
setPositionAndSelection(change, outerEditor, accessibilityService, codeEditorService);
|
|
829
|
-
} finally {
|
|
830
|
-
modelRef?.dispose();
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
registerEditorAction(GotoNextChangeAction);
|
|
835
|
-
MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
|
|
836
|
-
group: "7_change_nav",
|
|
837
|
-
command: {
|
|
838
|
-
id: "editor.action.dirtydiff.next",
|
|
839
|
-
title: ( localize(12363, "Next &&Change"))
|
|
840
|
-
},
|
|
841
|
-
order: 1
|
|
842
|
-
});
|
|
843
|
-
MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
|
|
844
|
-
group: "7_change_nav",
|
|
845
|
-
command: {
|
|
846
|
-
id: "editor.action.dirtydiff.previous",
|
|
847
|
-
title: ( localize(12364, "Previous &&Change"))
|
|
848
|
-
},
|
|
849
|
-
order: 2
|
|
850
|
-
});
|
|
851
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
852
|
-
id: "closeQuickDiff",
|
|
853
|
-
weight: KeybindingWeight.EditorContrib + 50,
|
|
854
|
-
primary: KeyCode.Escape,
|
|
855
|
-
secondary: [KeyMod.Shift | KeyCode.Escape],
|
|
856
|
-
when: ( ContextKeyExpr.and(isQuickDiffVisible)),
|
|
857
|
-
handler: accessor => {
|
|
858
|
-
const outerEditor = getOuterEditorFromDiffEditor(accessor);
|
|
859
|
-
if (!outerEditor) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const controller = QuickDiffEditorController.get(outerEditor);
|
|
863
|
-
if (!controller) {
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
controller.close();
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
870
|
-
id: "toggleQuickDiffWidgetFocus",
|
|
871
|
-
weight: KeybindingWeight.EditorContrib,
|
|
872
|
-
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.F2),
|
|
873
|
-
when: isQuickDiffVisible,
|
|
874
|
-
handler: accessor => {
|
|
875
|
-
const outerEditor = getOuterEditorFromDiffEditor(accessor);
|
|
876
|
-
if (!outerEditor) {
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
const controller = QuickDiffEditorController.get(outerEditor);
|
|
880
|
-
if (!controller) {
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
controller.toggleFocus();
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
function setPositionAndSelection(change, editor, accessibilityService, codeEditorService) {
|
|
887
|
-
const position = ( new Position(change.modifiedStartLineNumber, 1));
|
|
888
|
-
editor.setPosition(position);
|
|
889
|
-
editor.revealPositionInCenter(position);
|
|
890
|
-
if (accessibilityService.isScreenReaderOptimized()) {
|
|
891
|
-
editor.setSelection({
|
|
892
|
-
startLineNumber: change.modifiedStartLineNumber,
|
|
893
|
-
startColumn: 0,
|
|
894
|
-
endLineNumber: change.modifiedStartLineNumber,
|
|
895
|
-
endColumn: Number.MAX_VALUE
|
|
896
|
-
});
|
|
897
|
-
codeEditorService.getActiveCodeEditor()?.writeScreenReaderContent("diff-navigation");
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
async function playAccessibilitySymbolForChange(change, accessibilitySignalService) {
|
|
901
|
-
const changeType = getChangeType(change);
|
|
902
|
-
switch (changeType) {
|
|
903
|
-
case ChangeType.Add:
|
|
904
|
-
accessibilitySignalService.playSignal(AccessibilitySignal.diffLineInserted, {
|
|
905
|
-
allowManyInParallel: true,
|
|
906
|
-
source: "quickDiffDecoration"
|
|
907
|
-
});
|
|
908
|
-
break;
|
|
909
|
-
case ChangeType.Delete:
|
|
910
|
-
accessibilitySignalService.playSignal(AccessibilitySignal.diffLineDeleted, {
|
|
911
|
-
allowManyInParallel: true,
|
|
912
|
-
source: "quickDiffDecoration"
|
|
913
|
-
});
|
|
914
|
-
break;
|
|
915
|
-
case ChangeType.Modify:
|
|
916
|
-
accessibilitySignalService.playSignal(AccessibilitySignal.diffLineModified, {
|
|
917
|
-
allowManyInParallel: true,
|
|
918
|
-
source: "quickDiffDecoration"
|
|
919
|
-
});
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
function getOuterEditorFromDiffEditor(accessor) {
|
|
924
|
-
const diffEditors = accessor.get(ICodeEditorService).listDiffEditors();
|
|
925
|
-
for (const diffEditor of diffEditors) {
|
|
926
|
-
if (diffEditor.hasTextFocus() && diffEditor instanceof EmbeddedDiffEditorWidget) {
|
|
927
|
-
return diffEditor.getParentEditor();
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
return getOuterEditor(accessor);
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
export { GotoNextChangeAction, GotoPreviousChangeAction, QuickDiffEditorController, QuickDiffPickerBaseAction, QuickDiffPickerViewItem, ShowNextChangeAction, ShowPreviousChangeAction, isQuickDiffVisible };
|