@theia/scm 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/lib/browser/scm-commit-widget.js +1 -1
- package/lib/browser/scm-contribution.js +5 -5
- package/package.json +6 -6
- package/src/browser/decorations/scm-decorations-service.ts +102 -102
- package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
- package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
- package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
- package/src/browser/dirty-diff/content-lines.ts +121 -121
- package/src/browser/dirty-diff/diff-computer.spec.ts +455 -455
- package/src/browser/dirty-diff/diff-computer.ts +177 -177
- package/src/browser/dirty-diff/dirty-diff-decorator.ts +114 -114
- package/src/browser/dirty-diff/dirty-diff-module.ts +33 -33
- package/src/browser/dirty-diff/dirty-diff-navigator.ts +288 -288
- package/src/browser/dirty-diff/dirty-diff-widget.ts +364 -364
- package/src/browser/scm-amend-component.tsx +600 -600
- package/src/browser/scm-amend-widget.tsx +77 -77
- package/src/browser/scm-avatar-service.ts +27 -27
- package/src/browser/scm-colors.ts +21 -21
- package/src/browser/scm-commit-widget.tsx +215 -215
- package/src/browser/scm-context-key-service.ts +46 -46
- package/src/browser/scm-contribution.ts +452 -452
- package/src/browser/scm-frontend-module.ts +149 -149
- package/src/browser/scm-groups-tree-model.ts +78 -78
- package/src/browser/scm-input.ts +164 -164
- package/src/browser/scm-layout-migrations.ts +64 -64
- package/src/browser/scm-no-repository-widget.tsx +41 -41
- package/src/browser/scm-preferences.ts +63 -63
- package/src/browser/scm-provider.ts +91 -91
- package/src/browser/scm-quick-open-service.ts +48 -48
- package/src/browser/scm-repository.ts +52 -52
- package/src/browser/scm-service.ts +108 -108
- package/src/browser/scm-tree-label-provider.ts +44 -44
- package/src/browser/scm-tree-model.ts +405 -405
- package/src/browser/scm-tree-widget.tsx +838 -838
- package/src/browser/scm-widget.tsx +204 -204
- package/src/browser/style/dirty-diff-decorator.css +53 -53
- package/src/browser/style/dirty-diff.css +50 -50
- package/src/browser/style/index.css +271 -271
- package/src/browser/style/scm-amend-component.css +94 -94
- package/src/browser/style/scm.svg +4 -4
|
@@ -1,452 +1,452 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. 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
|
-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
17
|
-
import { Emitter } from '@theia/core/lib/common/event';
|
|
18
|
-
import {
|
|
19
|
-
AbstractViewContribution,
|
|
20
|
-
FrontendApplicationContribution, LabelProvider,
|
|
21
|
-
StatusBar,
|
|
22
|
-
StatusBarAlignment,
|
|
23
|
-
StatusBarEntry,
|
|
24
|
-
KeybindingRegistry,
|
|
25
|
-
ViewContainerTitleOptions,
|
|
26
|
-
codicon,
|
|
27
|
-
StylingParticipant,
|
|
28
|
-
ColorTheme,
|
|
29
|
-
CssStyleCollector
|
|
30
|
-
} from '@theia/core/lib/browser';
|
|
31
|
-
import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
32
|
-
import { CommandRegistry, Command, Disposable, DisposableCollection, CommandService, MenuModelRegistry } from '@theia/core/lib/common';
|
|
33
|
-
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
|
|
34
|
-
import { ScmService } from './scm-service';
|
|
35
|
-
import { ScmWidget } from '../browser/scm-widget';
|
|
36
|
-
import URI from '@theia/core/lib/common/uri';
|
|
37
|
-
import { ScmQuickOpenService } from './scm-quick-open-service';
|
|
38
|
-
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
39
|
-
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
|
40
|
-
import { Color } from '@theia/core/lib/common/color';
|
|
41
|
-
import { ScmColors } from './scm-colors';
|
|
42
|
-
import { ScmCommand } from './scm-provider';
|
|
43
|
-
import { ScmDecorationsService } from '../browser/decorations/scm-decorations-service';
|
|
44
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
45
|
-
import { isHighContrast } from '@theia/core/lib/common/theme';
|
|
46
|
-
import { EditorMainMenu } from '@theia/editor/lib/browser';
|
|
47
|
-
import { DirtyDiffNavigator } from './dirty-diff/dirty-diff-navigator';
|
|
48
|
-
|
|
49
|
-
export const SCM_WIDGET_FACTORY_ID = ScmWidget.ID;
|
|
50
|
-
export const SCM_VIEW_CONTAINER_ID = 'scm-view-container';
|
|
51
|
-
export const SCM_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
|
|
52
|
-
label: nls.localizeByDefault('Source Control'),
|
|
53
|
-
iconClass: codicon('source-control'),
|
|
54
|
-
closeable: true
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export namespace ScmMenus {
|
|
58
|
-
export const CHANGES_GROUP = [...EditorMainMenu.GO, '6_changes_group'];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export namespace SCM_COMMANDS {
|
|
62
|
-
export const CHANGE_REPOSITORY = {
|
|
63
|
-
id: 'scm.change.repository',
|
|
64
|
-
category: nls.localizeByDefault('Source Control'),
|
|
65
|
-
originalCategory: 'Source Control',
|
|
66
|
-
label: nls.localize('theia/scm/changeRepository', 'Change Repository...'),
|
|
67
|
-
originalLabel: 'Change Repository...'
|
|
68
|
-
};
|
|
69
|
-
export const ACCEPT_INPUT = {
|
|
70
|
-
id: 'scm.acceptInput'
|
|
71
|
-
};
|
|
72
|
-
export const TREE_VIEW_MODE = {
|
|
73
|
-
id: 'scm.viewmode.tree',
|
|
74
|
-
tooltip: nls.localizeByDefault('View as Tree'),
|
|
75
|
-
iconClass: codicon('list-tree'),
|
|
76
|
-
originalLabel: 'View as Tree',
|
|
77
|
-
label: nls.localizeByDefault('View as Tree')
|
|
78
|
-
};
|
|
79
|
-
export const LIST_VIEW_MODE = {
|
|
80
|
-
id: 'scm.viewmode.list',
|
|
81
|
-
tooltip: nls.localizeByDefault('View as List'),
|
|
82
|
-
iconClass: codicon('list-flat'),
|
|
83
|
-
originalLabel: 'View as List',
|
|
84
|
-
label: nls.localizeByDefault('View as List')
|
|
85
|
-
};
|
|
86
|
-
export const COLLAPSE_ALL = {
|
|
87
|
-
id: 'scm.collapseAll',
|
|
88
|
-
category: nls.localizeByDefault('Source Control'),
|
|
89
|
-
originalCategory: 'Source Control',
|
|
90
|
-
tooltip: nls.localizeByDefault('Collapse All'),
|
|
91
|
-
iconClass: codicon('collapse-all'),
|
|
92
|
-
label: nls.localizeByDefault('Collapse All'),
|
|
93
|
-
originalLabel: 'Collapse All'
|
|
94
|
-
};
|
|
95
|
-
export const GOTO_NEXT_CHANGE = Command.toDefaultLocalizedCommand({
|
|
96
|
-
id: 'workbench.action.editor.nextChange',
|
|
97
|
-
category: 'Source Control',
|
|
98
|
-
label: 'Go to Next Change'
|
|
99
|
-
});
|
|
100
|
-
export const GOTO_PREVIOUS_CHANGE = Command.toDefaultLocalizedCommand({
|
|
101
|
-
id: 'workbench.action.editor.previousChange',
|
|
102
|
-
category: 'Source Control',
|
|
103
|
-
label: 'Go to Previous Change'
|
|
104
|
-
});
|
|
105
|
-
export const SHOW_NEXT_CHANGE = Command.toDefaultLocalizedCommand({
|
|
106
|
-
id: 'editor.action.dirtydiff.next',
|
|
107
|
-
category: 'Source Control',
|
|
108
|
-
label: 'Show Next Change'
|
|
109
|
-
});
|
|
110
|
-
export const SHOW_PREVIOUS_CHANGE = Command.toDefaultLocalizedCommand({
|
|
111
|
-
id: 'editor.action.dirtydiff.previous',
|
|
112
|
-
category: 'Source Control',
|
|
113
|
-
label: 'Show Previous Change'
|
|
114
|
-
});
|
|
115
|
-
export const CLOSE_CHANGE_PEEK_VIEW = {
|
|
116
|
-
id: 'editor.action.dirtydiff.close',
|
|
117
|
-
category: nls.localizeByDefault('Source Control'),
|
|
118
|
-
originalCategory: 'Source Control',
|
|
119
|
-
label: nls.localize('theia/scm/dirtyDiff/close', 'Close Change Peek View'),
|
|
120
|
-
originalLabel: 'Close Change Peek View'
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export { ScmColors };
|
|
125
|
-
|
|
126
|
-
@injectable()
|
|
127
|
-
export class ScmContribution extends AbstractViewContribution<ScmWidget> implements
|
|
128
|
-
FrontendApplicationContribution,
|
|
129
|
-
TabBarToolbarContribution,
|
|
130
|
-
ColorContribution,
|
|
131
|
-
StylingParticipant {
|
|
132
|
-
|
|
133
|
-
@inject(StatusBar) protected readonly statusBar: StatusBar;
|
|
134
|
-
@inject(ScmService) protected readonly scmService: ScmService;
|
|
135
|
-
@inject(ScmQuickOpenService) protected readonly scmQuickOpenService: ScmQuickOpenService;
|
|
136
|
-
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
|
|
137
|
-
@inject(CommandService) protected readonly commands: CommandService;
|
|
138
|
-
@inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
|
|
139
|
-
@inject(ContextKeyService) protected readonly contextKeys: ContextKeyService;
|
|
140
|
-
@inject(ScmDecorationsService) protected readonly scmDecorationsService: ScmDecorationsService;
|
|
141
|
-
@inject(DirtyDiffNavigator) protected readonly dirtyDiffNavigator: DirtyDiffNavigator;
|
|
142
|
-
|
|
143
|
-
protected scmFocus: ContextKey<boolean>;
|
|
144
|
-
|
|
145
|
-
constructor() {
|
|
146
|
-
super({
|
|
147
|
-
viewContainerId: SCM_VIEW_CONTAINER_ID,
|
|
148
|
-
widgetId: SCM_WIDGET_FACTORY_ID,
|
|
149
|
-
widgetName: SCM_VIEW_CONTAINER_TITLE_OPTIONS.label,
|
|
150
|
-
defaultWidgetOptions: {
|
|
151
|
-
area: 'left',
|
|
152
|
-
rank: 300
|
|
153
|
-
},
|
|
154
|
-
toggleCommandId: 'scmView:toggle',
|
|
155
|
-
toggleKeybinding: 'ctrlcmd+shift+g'
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@postConstruct()
|
|
160
|
-
protected init(): void {
|
|
161
|
-
this.scmFocus = this.contextKeys.createKey('scmFocus', false);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async initializeLayout(): Promise<void> {
|
|
165
|
-
await this.openView();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
onStart(): void {
|
|
169
|
-
this.updateStatusBar();
|
|
170
|
-
this.scmService.onDidAddRepository(() => this.updateStatusBar());
|
|
171
|
-
this.scmService.onDidRemoveRepository(() => this.updateStatusBar());
|
|
172
|
-
this.scmService.onDidChangeSelectedRepository(() => this.updateStatusBar());
|
|
173
|
-
this.scmService.onDidChangeStatusBarCommands(() => this.updateStatusBar());
|
|
174
|
-
this.labelProvider.onDidChange(() => this.updateStatusBar());
|
|
175
|
-
|
|
176
|
-
this.updateContextKeys();
|
|
177
|
-
this.shell.onDidChangeCurrentWidget(() => this.updateContextKeys());
|
|
178
|
-
|
|
179
|
-
this.scmDecorationsService.onDirtyDiffUpdate(update => this.dirtyDiffNavigator.handleDirtyDiffUpdate(update));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
protected updateContextKeys(): void {
|
|
183
|
-
this.scmFocus.set(this.shell.currentWidget instanceof ScmWidget);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
override registerCommands(commandRegistry: CommandRegistry): void {
|
|
187
|
-
super.registerCommands(commandRegistry);
|
|
188
|
-
commandRegistry.registerCommand(SCM_COMMANDS.CHANGE_REPOSITORY, {
|
|
189
|
-
execute: () => this.scmQuickOpenService.changeRepository(),
|
|
190
|
-
isEnabled: () => this.scmService.repositories.length > 1
|
|
191
|
-
});
|
|
192
|
-
commandRegistry.registerCommand(SCM_COMMANDS.ACCEPT_INPUT, {
|
|
193
|
-
execute: () => this.acceptInput(),
|
|
194
|
-
isEnabled: () => !!this.scmFocus.get() && !!this.acceptInputCommand()
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Note that commands for dirty diff navigation need to be always available.
|
|
198
|
-
// This is consistent with behavior in VS Code, and also with other similar commands (such as `Next Problem/Previous Problem`) in Theia.
|
|
199
|
-
// See https://github.com/eclipse-theia/theia/pull/13104#discussion_r1497316614 for a detailed discussion.
|
|
200
|
-
commandRegistry.registerCommand(SCM_COMMANDS.GOTO_NEXT_CHANGE, {
|
|
201
|
-
execute: () => this.dirtyDiffNavigator.gotoNextChange()
|
|
202
|
-
});
|
|
203
|
-
commandRegistry.registerCommand(SCM_COMMANDS.GOTO_PREVIOUS_CHANGE, {
|
|
204
|
-
execute: () => this.dirtyDiffNavigator.gotoPreviousChange()
|
|
205
|
-
});
|
|
206
|
-
commandRegistry.registerCommand(SCM_COMMANDS.SHOW_NEXT_CHANGE, {
|
|
207
|
-
execute: () => this.dirtyDiffNavigator.showNextChange()
|
|
208
|
-
});
|
|
209
|
-
commandRegistry.registerCommand(SCM_COMMANDS.SHOW_PREVIOUS_CHANGE, {
|
|
210
|
-
execute: () => this.dirtyDiffNavigator.showPreviousChange()
|
|
211
|
-
});
|
|
212
|
-
commandRegistry.registerCommand(SCM_COMMANDS.CLOSE_CHANGE_PEEK_VIEW, {
|
|
213
|
-
execute: () => this.dirtyDiffNavigator.closeChangePeekView()
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
override registerMenus(menus: MenuModelRegistry): void {
|
|
218
|
-
super.registerMenus(menus);
|
|
219
|
-
menus.registerMenuAction(ScmMenus.CHANGES_GROUP, {
|
|
220
|
-
commandId: SCM_COMMANDS.SHOW_NEXT_CHANGE.id,
|
|
221
|
-
label: nls.localizeByDefault('Next Change'),
|
|
222
|
-
order: '1'
|
|
223
|
-
});
|
|
224
|
-
menus.registerMenuAction(ScmMenus.CHANGES_GROUP, {
|
|
225
|
-
commandId: SCM_COMMANDS.SHOW_PREVIOUS_CHANGE.id,
|
|
226
|
-
label: nls.localizeByDefault('Previous Change'),
|
|
227
|
-
order: '2'
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
|
232
|
-
const viewModeEmitter = new Emitter<void>();
|
|
233
|
-
const registerToggleViewItem = (command: Command, mode: 'tree' | 'list') => {
|
|
234
|
-
const id = command.id;
|
|
235
|
-
const item: TabBarToolbarItem = {
|
|
236
|
-
id,
|
|
237
|
-
command: id,
|
|
238
|
-
tooltip: command.label,
|
|
239
|
-
onDidChange: viewModeEmitter.event
|
|
240
|
-
};
|
|
241
|
-
this.commandRegistry.registerCommand({ id, iconClass: command && command.iconClass }, {
|
|
242
|
-
execute: widget => {
|
|
243
|
-
if (widget instanceof ScmWidget) {
|
|
244
|
-
widget.viewMode = mode;
|
|
245
|
-
viewModeEmitter.fire();
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
isVisible: widget => {
|
|
249
|
-
if (widget instanceof ScmWidget) {
|
|
250
|
-
return !!this.scmService.selectedRepository
|
|
251
|
-
&& widget.viewMode !== mode;
|
|
252
|
-
}
|
|
253
|
-
return false;
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
registry.registerItem(item);
|
|
257
|
-
};
|
|
258
|
-
registerToggleViewItem(SCM_COMMANDS.TREE_VIEW_MODE, 'tree');
|
|
259
|
-
registerToggleViewItem(SCM_COMMANDS.LIST_VIEW_MODE, 'list');
|
|
260
|
-
|
|
261
|
-
this.commandRegistry.registerCommand(SCM_COMMANDS.COLLAPSE_ALL, {
|
|
262
|
-
execute: widget => {
|
|
263
|
-
if (widget instanceof ScmWidget && widget.viewMode === 'tree') {
|
|
264
|
-
widget.collapseScmTree();
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
isVisible: widget => {
|
|
268
|
-
if (widget instanceof ScmWidget) {
|
|
269
|
-
return !!this.scmService.selectedRepository && widget.viewMode === 'tree';
|
|
270
|
-
}
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
registry.registerItem({
|
|
276
|
-
...SCM_COMMANDS.COLLAPSE_ALL,
|
|
277
|
-
command: SCM_COMMANDS.COLLAPSE_ALL.id
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
override registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
282
|
-
super.registerKeybindings(keybindings);
|
|
283
|
-
keybindings.registerKeybinding({
|
|
284
|
-
command: SCM_COMMANDS.ACCEPT_INPUT.id,
|
|
285
|
-
keybinding: 'ctrlcmd+enter',
|
|
286
|
-
when: 'scmFocus'
|
|
287
|
-
});
|
|
288
|
-
keybindings.registerKeybinding({
|
|
289
|
-
command: SCM_COMMANDS.GOTO_NEXT_CHANGE.id,
|
|
290
|
-
keybinding: 'alt+f5',
|
|
291
|
-
when: 'editorTextFocus'
|
|
292
|
-
});
|
|
293
|
-
keybindings.registerKeybinding({
|
|
294
|
-
command: SCM_COMMANDS.GOTO_PREVIOUS_CHANGE.id,
|
|
295
|
-
keybinding: 'shift+alt+f5',
|
|
296
|
-
when: 'editorTextFocus'
|
|
297
|
-
});
|
|
298
|
-
keybindings.registerKeybinding({
|
|
299
|
-
command: SCM_COMMANDS.SHOW_NEXT_CHANGE.id,
|
|
300
|
-
keybinding: 'alt+f3',
|
|
301
|
-
when: 'editorTextFocus'
|
|
302
|
-
});
|
|
303
|
-
keybindings.registerKeybinding({
|
|
304
|
-
command: SCM_COMMANDS.SHOW_PREVIOUS_CHANGE.id,
|
|
305
|
-
keybinding: 'shift+alt+f3',
|
|
306
|
-
when: 'editorTextFocus'
|
|
307
|
-
});
|
|
308
|
-
keybindings.registerKeybinding({
|
|
309
|
-
command: SCM_COMMANDS.CLOSE_CHANGE_PEEK_VIEW.id,
|
|
310
|
-
keybinding: 'esc',
|
|
311
|
-
when: 'dirtyDiffVisible'
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
protected async acceptInput(): Promise<void> {
|
|
316
|
-
const command = this.acceptInputCommand();
|
|
317
|
-
if (command && command.command) {
|
|
318
|
-
await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
protected acceptInputCommand(): ScmCommand | undefined {
|
|
322
|
-
const repository = this.scmService.selectedRepository;
|
|
323
|
-
if (!repository) {
|
|
324
|
-
return undefined;
|
|
325
|
-
}
|
|
326
|
-
return repository.provider.acceptInputCommand;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
protected readonly statusBarDisposable = new DisposableCollection();
|
|
330
|
-
protected updateStatusBar(): void {
|
|
331
|
-
this.statusBarDisposable.dispose();
|
|
332
|
-
const repository = this.scmService.selectedRepository;
|
|
333
|
-
if (!repository) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const name = this.labelProvider.getName(new URI(repository.provider.rootUri));
|
|
337
|
-
if (this.scmService.repositories.length > 1) {
|
|
338
|
-
this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
|
|
339
|
-
text: `$(database) ${name}`,
|
|
340
|
-
tooltip: name.toString(),
|
|
341
|
-
command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
|
|
342
|
-
alignment: StatusBarAlignment.LEFT,
|
|
343
|
-
priority: 100
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
|
|
347
|
-
this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
|
|
348
|
-
text: value.title,
|
|
349
|
-
tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
|
|
350
|
-
command: value.command,
|
|
351
|
-
arguments: value.arguments,
|
|
352
|
-
alignment: StatusBarAlignment.LEFT,
|
|
353
|
-
priority: 100
|
|
354
|
-
}));
|
|
355
|
-
}
|
|
356
|
-
protected setStatusBarEntry(id: string, entry: StatusBarEntry): void {
|
|
357
|
-
this.statusBar.setElement(id, entry);
|
|
358
|
-
this.statusBarDisposable.push(Disposable.create(() => this.statusBar.removeElement(id)));
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
|
|
363
|
-
*/
|
|
364
|
-
registerColors(colors: ColorRegistry): void {
|
|
365
|
-
colors.register(
|
|
366
|
-
{
|
|
367
|
-
id: ScmColors.editorGutterModifiedBackground, defaults: {
|
|
368
|
-
dark: '#1B81A8',
|
|
369
|
-
light: '#2090D3',
|
|
370
|
-
hcDark: '#1B81A8',
|
|
371
|
-
hcLight: '#2090D3'
|
|
372
|
-
}, description: 'Editor gutter background color for lines that are modified.'
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
id: ScmColors.editorGutterAddedBackground, defaults: {
|
|
376
|
-
dark: '#487E02',
|
|
377
|
-
light: '#48985D',
|
|
378
|
-
hcDark: '#487E02',
|
|
379
|
-
hcLight: '#48985D'
|
|
380
|
-
}, description: 'Editor gutter background color for lines that are added.'
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
id: ScmColors.editorGutterDeletedBackground, defaults: {
|
|
384
|
-
dark: 'editorError.foreground',
|
|
385
|
-
light: 'editorError.foreground',
|
|
386
|
-
hcDark: 'editorError.foreground',
|
|
387
|
-
hcLight: 'editorError.foreground'
|
|
388
|
-
}, description: 'Editor gutter background color for lines that are deleted.'
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
id: 'minimapGutter.modifiedBackground', defaults: {
|
|
392
|
-
dark: 'editorGutter.modifiedBackground',
|
|
393
|
-
light: 'editorGutter.modifiedBackground',
|
|
394
|
-
hcDark: 'editorGutter.modifiedBackground',
|
|
395
|
-
hcLight: 'editorGutter.modifiedBackground'
|
|
396
|
-
}, description: 'Minimap gutter background color for lines that are modified.'
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
id: 'minimapGutter.addedBackground', defaults: {
|
|
400
|
-
dark: 'editorGutter.addedBackground',
|
|
401
|
-
light: 'editorGutter.addedBackground',
|
|
402
|
-
hcDark: 'editorGutter.modifiedBackground',
|
|
403
|
-
hcLight: 'editorGutter.modifiedBackground'
|
|
404
|
-
}, description: 'Minimap gutter background color for lines that are added.'
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
id: 'minimapGutter.deletedBackground', defaults: {
|
|
408
|
-
dark: 'editorGutter.deletedBackground',
|
|
409
|
-
light: 'editorGutter.deletedBackground',
|
|
410
|
-
hcDark: 'editorGutter.deletedBackground',
|
|
411
|
-
hcLight: 'editorGutter.deletedBackground'
|
|
412
|
-
}, description: 'Minimap gutter background color for lines that are deleted.'
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
id: 'editorOverviewRuler.modifiedForeground', defaults: {
|
|
416
|
-
dark: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
417
|
-
light: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
418
|
-
hcDark: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
419
|
-
hcLight: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
|
|
420
|
-
}, description: 'Overview ruler marker color for modified content.'
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
id: 'editorOverviewRuler.addedForeground', defaults: {
|
|
424
|
-
dark: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
425
|
-
light: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
426
|
-
hcDark: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
427
|
-
hcLight: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
|
|
428
|
-
}, description: 'Overview ruler marker color for added content.'
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
id: 'editorOverviewRuler.deletedForeground', defaults: {
|
|
432
|
-
dark: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
433
|
-
light: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
434
|
-
hcDark: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
435
|
-
hcLight: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
|
|
436
|
-
}, description: 'Overview ruler marker color for deleted content.'
|
|
437
|
-
}
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
|
442
|
-
const contrastBorder = theme.getColor('contrastBorder');
|
|
443
|
-
if (contrastBorder && isHighContrast(theme.type)) {
|
|
444
|
-
collector.addRule(`
|
|
445
|
-
.theia-scm-input-message-container textarea {
|
|
446
|
-
outline: var(--theia-border-width) solid ${contrastBorder};
|
|
447
|
-
outline-offset: -1px;
|
|
448
|
-
}
|
|
449
|
-
`);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. 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
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
17
|
+
import { Emitter } from '@theia/core/lib/common/event';
|
|
18
|
+
import {
|
|
19
|
+
AbstractViewContribution,
|
|
20
|
+
FrontendApplicationContribution, LabelProvider,
|
|
21
|
+
StatusBar,
|
|
22
|
+
StatusBarAlignment,
|
|
23
|
+
StatusBarEntry,
|
|
24
|
+
KeybindingRegistry,
|
|
25
|
+
ViewContainerTitleOptions,
|
|
26
|
+
codicon,
|
|
27
|
+
StylingParticipant,
|
|
28
|
+
ColorTheme,
|
|
29
|
+
CssStyleCollector
|
|
30
|
+
} from '@theia/core/lib/browser';
|
|
31
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
32
|
+
import { CommandRegistry, Command, Disposable, DisposableCollection, CommandService, MenuModelRegistry } from '@theia/core/lib/common';
|
|
33
|
+
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
|
|
34
|
+
import { ScmService } from './scm-service';
|
|
35
|
+
import { ScmWidget } from '../browser/scm-widget';
|
|
36
|
+
import URI from '@theia/core/lib/common/uri';
|
|
37
|
+
import { ScmQuickOpenService } from './scm-quick-open-service';
|
|
38
|
+
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
39
|
+
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
|
40
|
+
import { Color } from '@theia/core/lib/common/color';
|
|
41
|
+
import { ScmColors } from './scm-colors';
|
|
42
|
+
import { ScmCommand } from './scm-provider';
|
|
43
|
+
import { ScmDecorationsService } from '../browser/decorations/scm-decorations-service';
|
|
44
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
45
|
+
import { isHighContrast } from '@theia/core/lib/common/theme';
|
|
46
|
+
import { EditorMainMenu } from '@theia/editor/lib/browser';
|
|
47
|
+
import { DirtyDiffNavigator } from './dirty-diff/dirty-diff-navigator';
|
|
48
|
+
|
|
49
|
+
export const SCM_WIDGET_FACTORY_ID = ScmWidget.ID;
|
|
50
|
+
export const SCM_VIEW_CONTAINER_ID = 'scm-view-container';
|
|
51
|
+
export const SCM_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
|
|
52
|
+
label: nls.localizeByDefault('Source Control'),
|
|
53
|
+
iconClass: codicon('source-control'),
|
|
54
|
+
closeable: true
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export namespace ScmMenus {
|
|
58
|
+
export const CHANGES_GROUP = [...EditorMainMenu.GO, '6_changes_group'];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export namespace SCM_COMMANDS {
|
|
62
|
+
export const CHANGE_REPOSITORY = {
|
|
63
|
+
id: 'scm.change.repository',
|
|
64
|
+
category: nls.localizeByDefault('Source Control'),
|
|
65
|
+
originalCategory: 'Source Control',
|
|
66
|
+
label: nls.localize('theia/scm/changeRepository', 'Change Repository...'),
|
|
67
|
+
originalLabel: 'Change Repository...'
|
|
68
|
+
};
|
|
69
|
+
export const ACCEPT_INPUT = {
|
|
70
|
+
id: 'scm.acceptInput'
|
|
71
|
+
};
|
|
72
|
+
export const TREE_VIEW_MODE = {
|
|
73
|
+
id: 'scm.viewmode.tree',
|
|
74
|
+
tooltip: nls.localizeByDefault('View as Tree'),
|
|
75
|
+
iconClass: codicon('list-tree'),
|
|
76
|
+
originalLabel: 'View as Tree',
|
|
77
|
+
label: nls.localizeByDefault('View as Tree')
|
|
78
|
+
};
|
|
79
|
+
export const LIST_VIEW_MODE = {
|
|
80
|
+
id: 'scm.viewmode.list',
|
|
81
|
+
tooltip: nls.localizeByDefault('View as List'),
|
|
82
|
+
iconClass: codicon('list-flat'),
|
|
83
|
+
originalLabel: 'View as List',
|
|
84
|
+
label: nls.localizeByDefault('View as List')
|
|
85
|
+
};
|
|
86
|
+
export const COLLAPSE_ALL = {
|
|
87
|
+
id: 'scm.collapseAll',
|
|
88
|
+
category: nls.localizeByDefault('Source Control'),
|
|
89
|
+
originalCategory: 'Source Control',
|
|
90
|
+
tooltip: nls.localizeByDefault('Collapse All'),
|
|
91
|
+
iconClass: codicon('collapse-all'),
|
|
92
|
+
label: nls.localizeByDefault('Collapse All'),
|
|
93
|
+
originalLabel: 'Collapse All'
|
|
94
|
+
};
|
|
95
|
+
export const GOTO_NEXT_CHANGE = Command.toDefaultLocalizedCommand({
|
|
96
|
+
id: 'workbench.action.editor.nextChange',
|
|
97
|
+
category: 'Source Control',
|
|
98
|
+
label: 'Go to Next Change'
|
|
99
|
+
});
|
|
100
|
+
export const GOTO_PREVIOUS_CHANGE = Command.toDefaultLocalizedCommand({
|
|
101
|
+
id: 'workbench.action.editor.previousChange',
|
|
102
|
+
category: 'Source Control',
|
|
103
|
+
label: 'Go to Previous Change'
|
|
104
|
+
});
|
|
105
|
+
export const SHOW_NEXT_CHANGE = Command.toDefaultLocalizedCommand({
|
|
106
|
+
id: 'editor.action.dirtydiff.next',
|
|
107
|
+
category: 'Source Control',
|
|
108
|
+
label: 'Show Next Change'
|
|
109
|
+
});
|
|
110
|
+
export const SHOW_PREVIOUS_CHANGE = Command.toDefaultLocalizedCommand({
|
|
111
|
+
id: 'editor.action.dirtydiff.previous',
|
|
112
|
+
category: 'Source Control',
|
|
113
|
+
label: 'Show Previous Change'
|
|
114
|
+
});
|
|
115
|
+
export const CLOSE_CHANGE_PEEK_VIEW = {
|
|
116
|
+
id: 'editor.action.dirtydiff.close',
|
|
117
|
+
category: nls.localizeByDefault('Source Control'),
|
|
118
|
+
originalCategory: 'Source Control',
|
|
119
|
+
label: nls.localize('theia/scm/dirtyDiff/close', 'Close Change Peek View'),
|
|
120
|
+
originalLabel: 'Close Change Peek View'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { ScmColors };
|
|
125
|
+
|
|
126
|
+
@injectable()
|
|
127
|
+
export class ScmContribution extends AbstractViewContribution<ScmWidget> implements
|
|
128
|
+
FrontendApplicationContribution,
|
|
129
|
+
TabBarToolbarContribution,
|
|
130
|
+
ColorContribution,
|
|
131
|
+
StylingParticipant {
|
|
132
|
+
|
|
133
|
+
@inject(StatusBar) protected readonly statusBar: StatusBar;
|
|
134
|
+
@inject(ScmService) protected readonly scmService: ScmService;
|
|
135
|
+
@inject(ScmQuickOpenService) protected readonly scmQuickOpenService: ScmQuickOpenService;
|
|
136
|
+
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
|
|
137
|
+
@inject(CommandService) protected readonly commands: CommandService;
|
|
138
|
+
@inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
|
|
139
|
+
@inject(ContextKeyService) protected readonly contextKeys: ContextKeyService;
|
|
140
|
+
@inject(ScmDecorationsService) protected readonly scmDecorationsService: ScmDecorationsService;
|
|
141
|
+
@inject(DirtyDiffNavigator) protected readonly dirtyDiffNavigator: DirtyDiffNavigator;
|
|
142
|
+
|
|
143
|
+
protected scmFocus: ContextKey<boolean>;
|
|
144
|
+
|
|
145
|
+
constructor() {
|
|
146
|
+
super({
|
|
147
|
+
viewContainerId: SCM_VIEW_CONTAINER_ID,
|
|
148
|
+
widgetId: SCM_WIDGET_FACTORY_ID,
|
|
149
|
+
widgetName: SCM_VIEW_CONTAINER_TITLE_OPTIONS.label,
|
|
150
|
+
defaultWidgetOptions: {
|
|
151
|
+
area: 'left',
|
|
152
|
+
rank: 300
|
|
153
|
+
},
|
|
154
|
+
toggleCommandId: 'scmView:toggle',
|
|
155
|
+
toggleKeybinding: 'ctrlcmd+shift+g'
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@postConstruct()
|
|
160
|
+
protected init(): void {
|
|
161
|
+
this.scmFocus = this.contextKeys.createKey('scmFocus', false);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async initializeLayout(): Promise<void> {
|
|
165
|
+
await this.openView();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
onStart(): void {
|
|
169
|
+
this.updateStatusBar();
|
|
170
|
+
this.scmService.onDidAddRepository(() => this.updateStatusBar());
|
|
171
|
+
this.scmService.onDidRemoveRepository(() => this.updateStatusBar());
|
|
172
|
+
this.scmService.onDidChangeSelectedRepository(() => this.updateStatusBar());
|
|
173
|
+
this.scmService.onDidChangeStatusBarCommands(() => this.updateStatusBar());
|
|
174
|
+
this.labelProvider.onDidChange(() => this.updateStatusBar());
|
|
175
|
+
|
|
176
|
+
this.updateContextKeys();
|
|
177
|
+
this.shell.onDidChangeCurrentWidget(() => this.updateContextKeys());
|
|
178
|
+
|
|
179
|
+
this.scmDecorationsService.onDirtyDiffUpdate(update => this.dirtyDiffNavigator.handleDirtyDiffUpdate(update));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
protected updateContextKeys(): void {
|
|
183
|
+
this.scmFocus.set(this.shell.currentWidget instanceof ScmWidget);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
override registerCommands(commandRegistry: CommandRegistry): void {
|
|
187
|
+
super.registerCommands(commandRegistry);
|
|
188
|
+
commandRegistry.registerCommand(SCM_COMMANDS.CHANGE_REPOSITORY, {
|
|
189
|
+
execute: () => this.scmQuickOpenService.changeRepository(),
|
|
190
|
+
isEnabled: () => this.scmService.repositories.length > 1
|
|
191
|
+
});
|
|
192
|
+
commandRegistry.registerCommand(SCM_COMMANDS.ACCEPT_INPUT, {
|
|
193
|
+
execute: () => this.acceptInput(),
|
|
194
|
+
isEnabled: () => !!this.scmFocus.get() && !!this.acceptInputCommand()
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Note that commands for dirty diff navigation need to be always available.
|
|
198
|
+
// This is consistent with behavior in VS Code, and also with other similar commands (such as `Next Problem/Previous Problem`) in Theia.
|
|
199
|
+
// See https://github.com/eclipse-theia/theia/pull/13104#discussion_r1497316614 for a detailed discussion.
|
|
200
|
+
commandRegistry.registerCommand(SCM_COMMANDS.GOTO_NEXT_CHANGE, {
|
|
201
|
+
execute: () => this.dirtyDiffNavigator.gotoNextChange()
|
|
202
|
+
});
|
|
203
|
+
commandRegistry.registerCommand(SCM_COMMANDS.GOTO_PREVIOUS_CHANGE, {
|
|
204
|
+
execute: () => this.dirtyDiffNavigator.gotoPreviousChange()
|
|
205
|
+
});
|
|
206
|
+
commandRegistry.registerCommand(SCM_COMMANDS.SHOW_NEXT_CHANGE, {
|
|
207
|
+
execute: () => this.dirtyDiffNavigator.showNextChange()
|
|
208
|
+
});
|
|
209
|
+
commandRegistry.registerCommand(SCM_COMMANDS.SHOW_PREVIOUS_CHANGE, {
|
|
210
|
+
execute: () => this.dirtyDiffNavigator.showPreviousChange()
|
|
211
|
+
});
|
|
212
|
+
commandRegistry.registerCommand(SCM_COMMANDS.CLOSE_CHANGE_PEEK_VIEW, {
|
|
213
|
+
execute: () => this.dirtyDiffNavigator.closeChangePeekView()
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
override registerMenus(menus: MenuModelRegistry): void {
|
|
218
|
+
super.registerMenus(menus);
|
|
219
|
+
menus.registerMenuAction(ScmMenus.CHANGES_GROUP, {
|
|
220
|
+
commandId: SCM_COMMANDS.SHOW_NEXT_CHANGE.id,
|
|
221
|
+
label: nls.localizeByDefault('Next Change'),
|
|
222
|
+
order: '1'
|
|
223
|
+
});
|
|
224
|
+
menus.registerMenuAction(ScmMenus.CHANGES_GROUP, {
|
|
225
|
+
commandId: SCM_COMMANDS.SHOW_PREVIOUS_CHANGE.id,
|
|
226
|
+
label: nls.localizeByDefault('Previous Change'),
|
|
227
|
+
order: '2'
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
|
232
|
+
const viewModeEmitter = new Emitter<void>();
|
|
233
|
+
const registerToggleViewItem = (command: Command, mode: 'tree' | 'list') => {
|
|
234
|
+
const id = command.id;
|
|
235
|
+
const item: TabBarToolbarItem = {
|
|
236
|
+
id,
|
|
237
|
+
command: id,
|
|
238
|
+
tooltip: command.label,
|
|
239
|
+
onDidChange: viewModeEmitter.event
|
|
240
|
+
};
|
|
241
|
+
this.commandRegistry.registerCommand({ id, iconClass: command && command.iconClass }, {
|
|
242
|
+
execute: widget => {
|
|
243
|
+
if (widget instanceof ScmWidget) {
|
|
244
|
+
widget.viewMode = mode;
|
|
245
|
+
viewModeEmitter.fire();
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
isVisible: widget => {
|
|
249
|
+
if (widget instanceof ScmWidget) {
|
|
250
|
+
return !!this.scmService.selectedRepository
|
|
251
|
+
&& widget.viewMode !== mode;
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
registry.registerItem(item);
|
|
257
|
+
};
|
|
258
|
+
registerToggleViewItem(SCM_COMMANDS.TREE_VIEW_MODE, 'tree');
|
|
259
|
+
registerToggleViewItem(SCM_COMMANDS.LIST_VIEW_MODE, 'list');
|
|
260
|
+
|
|
261
|
+
this.commandRegistry.registerCommand(SCM_COMMANDS.COLLAPSE_ALL, {
|
|
262
|
+
execute: widget => {
|
|
263
|
+
if (widget instanceof ScmWidget && widget.viewMode === 'tree') {
|
|
264
|
+
widget.collapseScmTree();
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
isVisible: widget => {
|
|
268
|
+
if (widget instanceof ScmWidget) {
|
|
269
|
+
return !!this.scmService.selectedRepository && widget.viewMode === 'tree';
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
registry.registerItem({
|
|
276
|
+
...SCM_COMMANDS.COLLAPSE_ALL,
|
|
277
|
+
command: SCM_COMMANDS.COLLAPSE_ALL.id
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
override registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
282
|
+
super.registerKeybindings(keybindings);
|
|
283
|
+
keybindings.registerKeybinding({
|
|
284
|
+
command: SCM_COMMANDS.ACCEPT_INPUT.id,
|
|
285
|
+
keybinding: 'ctrlcmd+enter',
|
|
286
|
+
when: 'scmFocus'
|
|
287
|
+
});
|
|
288
|
+
keybindings.registerKeybinding({
|
|
289
|
+
command: SCM_COMMANDS.GOTO_NEXT_CHANGE.id,
|
|
290
|
+
keybinding: 'alt+f5',
|
|
291
|
+
when: 'editorTextFocus'
|
|
292
|
+
});
|
|
293
|
+
keybindings.registerKeybinding({
|
|
294
|
+
command: SCM_COMMANDS.GOTO_PREVIOUS_CHANGE.id,
|
|
295
|
+
keybinding: 'shift+alt+f5',
|
|
296
|
+
when: 'editorTextFocus'
|
|
297
|
+
});
|
|
298
|
+
keybindings.registerKeybinding({
|
|
299
|
+
command: SCM_COMMANDS.SHOW_NEXT_CHANGE.id,
|
|
300
|
+
keybinding: 'alt+f3',
|
|
301
|
+
when: 'editorTextFocus'
|
|
302
|
+
});
|
|
303
|
+
keybindings.registerKeybinding({
|
|
304
|
+
command: SCM_COMMANDS.SHOW_PREVIOUS_CHANGE.id,
|
|
305
|
+
keybinding: 'shift+alt+f3',
|
|
306
|
+
when: 'editorTextFocus'
|
|
307
|
+
});
|
|
308
|
+
keybindings.registerKeybinding({
|
|
309
|
+
command: SCM_COMMANDS.CLOSE_CHANGE_PEEK_VIEW.id,
|
|
310
|
+
keybinding: 'esc',
|
|
311
|
+
when: 'dirtyDiffVisible'
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
protected async acceptInput(): Promise<void> {
|
|
316
|
+
const command = this.acceptInputCommand();
|
|
317
|
+
if (command && command.command) {
|
|
318
|
+
await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
protected acceptInputCommand(): ScmCommand | undefined {
|
|
322
|
+
const repository = this.scmService.selectedRepository;
|
|
323
|
+
if (!repository) {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
return repository.provider.acceptInputCommand;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
protected readonly statusBarDisposable = new DisposableCollection();
|
|
330
|
+
protected updateStatusBar(): void {
|
|
331
|
+
this.statusBarDisposable.dispose();
|
|
332
|
+
const repository = this.scmService.selectedRepository;
|
|
333
|
+
if (!repository) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const name = this.labelProvider.getName(new URI(repository.provider.rootUri));
|
|
337
|
+
if (this.scmService.repositories.length > 1) {
|
|
338
|
+
this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
|
|
339
|
+
text: `$(database) ${name}`,
|
|
340
|
+
tooltip: name.toString(),
|
|
341
|
+
command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
|
|
342
|
+
alignment: StatusBarAlignment.LEFT,
|
|
343
|
+
priority: 100
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
|
|
347
|
+
this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
|
|
348
|
+
text: value.title,
|
|
349
|
+
tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
|
|
350
|
+
command: value.command,
|
|
351
|
+
arguments: value.arguments,
|
|
352
|
+
alignment: StatusBarAlignment.LEFT,
|
|
353
|
+
priority: 100
|
|
354
|
+
}));
|
|
355
|
+
}
|
|
356
|
+
protected setStatusBarEntry(id: string, entry: StatusBarEntry): void {
|
|
357
|
+
this.statusBar.setElement(id, entry);
|
|
358
|
+
this.statusBarDisposable.push(Disposable.create(() => this.statusBar.removeElement(id)));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
|
|
363
|
+
*/
|
|
364
|
+
registerColors(colors: ColorRegistry): void {
|
|
365
|
+
colors.register(
|
|
366
|
+
{
|
|
367
|
+
id: ScmColors.editorGutterModifiedBackground, defaults: {
|
|
368
|
+
dark: '#1B81A8',
|
|
369
|
+
light: '#2090D3',
|
|
370
|
+
hcDark: '#1B81A8',
|
|
371
|
+
hcLight: '#2090D3'
|
|
372
|
+
}, description: 'Editor gutter background color for lines that are modified.'
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
id: ScmColors.editorGutterAddedBackground, defaults: {
|
|
376
|
+
dark: '#487E02',
|
|
377
|
+
light: '#48985D',
|
|
378
|
+
hcDark: '#487E02',
|
|
379
|
+
hcLight: '#48985D'
|
|
380
|
+
}, description: 'Editor gutter background color for lines that are added.'
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
id: ScmColors.editorGutterDeletedBackground, defaults: {
|
|
384
|
+
dark: 'editorError.foreground',
|
|
385
|
+
light: 'editorError.foreground',
|
|
386
|
+
hcDark: 'editorError.foreground',
|
|
387
|
+
hcLight: 'editorError.foreground'
|
|
388
|
+
}, description: 'Editor gutter background color for lines that are deleted.'
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: 'minimapGutter.modifiedBackground', defaults: {
|
|
392
|
+
dark: 'editorGutter.modifiedBackground',
|
|
393
|
+
light: 'editorGutter.modifiedBackground',
|
|
394
|
+
hcDark: 'editorGutter.modifiedBackground',
|
|
395
|
+
hcLight: 'editorGutter.modifiedBackground'
|
|
396
|
+
}, description: 'Minimap gutter background color for lines that are modified.'
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
id: 'minimapGutter.addedBackground', defaults: {
|
|
400
|
+
dark: 'editorGutter.addedBackground',
|
|
401
|
+
light: 'editorGutter.addedBackground',
|
|
402
|
+
hcDark: 'editorGutter.modifiedBackground',
|
|
403
|
+
hcLight: 'editorGutter.modifiedBackground'
|
|
404
|
+
}, description: 'Minimap gutter background color for lines that are added.'
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: 'minimapGutter.deletedBackground', defaults: {
|
|
408
|
+
dark: 'editorGutter.deletedBackground',
|
|
409
|
+
light: 'editorGutter.deletedBackground',
|
|
410
|
+
hcDark: 'editorGutter.deletedBackground',
|
|
411
|
+
hcLight: 'editorGutter.deletedBackground'
|
|
412
|
+
}, description: 'Minimap gutter background color for lines that are deleted.'
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
id: 'editorOverviewRuler.modifiedForeground', defaults: {
|
|
416
|
+
dark: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
417
|
+
light: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
418
|
+
hcDark: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
|
|
419
|
+
hcLight: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
|
|
420
|
+
}, description: 'Overview ruler marker color for modified content.'
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
id: 'editorOverviewRuler.addedForeground', defaults: {
|
|
424
|
+
dark: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
425
|
+
light: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
426
|
+
hcDark: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
|
|
427
|
+
hcLight: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
|
|
428
|
+
}, description: 'Overview ruler marker color for added content.'
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
id: 'editorOverviewRuler.deletedForeground', defaults: {
|
|
432
|
+
dark: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
433
|
+
light: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
434
|
+
hcDark: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
|
|
435
|
+
hcLight: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
|
|
436
|
+
}, description: 'Overview ruler marker color for deleted content.'
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
|
442
|
+
const contrastBorder = theme.getColor('contrastBorder');
|
|
443
|
+
if (contrastBorder && isHighContrast(theme.type)) {
|
|
444
|
+
collector.addRule(`
|
|
445
|
+
.theia-scm-input-message-container textarea {
|
|
446
|
+
outline: var(--theia-border-width) solid ${contrastBorder};
|
|
447
|
+
outline-offset: -1px;
|
|
448
|
+
}
|
|
449
|
+
`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|