@theia/scm 1.34.2 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +31 -31
  3. package/lib/browser/decorations/scm-decorations-service.d.ts +14 -14
  4. package/lib/browser/decorations/scm-decorations-service.js +101 -101
  5. package/lib/browser/decorations/scm-navigator-decorator.d.ts +25 -25
  6. package/lib/browser/decorations/scm-navigator-decorator.js +132 -132
  7. package/lib/browser/decorations/scm-tab-bar-decorator.d.ts +17 -17
  8. package/lib/browser/decorations/scm-tab-bar-decorator.js +93 -93
  9. package/lib/browser/dirty-diff/content-lines.d.ts +12 -12
  10. package/lib/browser/dirty-diff/content-lines.js +106 -106
  11. package/lib/browser/dirty-diff/content-lines.spec.d.ts +1 -1
  12. package/lib/browser/dirty-diff/content-lines.spec.js +39 -39
  13. package/lib/browser/dirty-diff/diff-computer.d.ts +29 -29
  14. package/lib/browser/dirty-diff/diff-computer.js +102 -102
  15. package/lib/browser/dirty-diff/diff-computer.spec.d.ts +1 -1
  16. package/lib/browser/dirty-diff/diff-computer.spec.js +315 -315
  17. package/lib/browser/dirty-diff/dirty-diff-decorator.d.ts +14 -14
  18. package/lib/browser/dirty-diff/dirty-diff-decorator.js +98 -98
  19. package/lib/browser/dirty-diff/dirty-diff-module.d.ts +3 -3
  20. package/lib/browser/dirty-diff/dirty-diff-module.js +24 -24
  21. package/lib/browser/scm-amend-component.d.ts +123 -123
  22. package/lib/browser/scm-amend-component.js +423 -423
  23. package/lib/browser/scm-amend-widget.d.ts +20 -20
  24. package/lib/browser/scm-amend-widget.js +101 -101
  25. package/lib/browser/scm-avatar-service.d.ts +3 -3
  26. package/lib/browser/scm-avatar-service.js +36 -36
  27. package/lib/browser/scm-commit-widget.d.ts +52 -52
  28. package/lib/browser/scm-commit-widget.js +199 -199
  29. package/lib/browser/scm-context-key-service.d.ts +10 -10
  30. package/lib/browser/scm-context-key-service.js +58 -58
  31. package/lib/browser/scm-contribution.d.ts +83 -83
  32. package/lib/browser/scm-contribution.js +353 -353
  33. package/lib/browser/scm-frontend-module.d.ts +6 -6
  34. package/lib/browser/scm-frontend-module.js +130 -130
  35. package/lib/browser/scm-groups-tree-model.d.ts +14 -14
  36. package/lib/browser/scm-groups-tree-model.js +97 -97
  37. package/lib/browser/scm-input.d.ts +53 -53
  38. package/lib/browser/scm-input.js +127 -127
  39. package/lib/browser/scm-layout-migrations.d.ts +9 -9
  40. package/lib/browser/scm-layout-migrations.js +79 -79
  41. package/lib/browser/scm-no-repository-widget.d.ts +8 -8
  42. package/lib/browser/scm-no-repository-widget.js +49 -49
  43. package/lib/browser/scm-preferences.d.ts +11 -11
  44. package/lib/browser/scm-preferences.js +51 -51
  45. package/lib/browser/scm-provider.d.ts +56 -56
  46. package/lib/browser/scm-provider.js +19 -19
  47. package/lib/browser/scm-quick-open-service.d.ts +11 -11
  48. package/lib/browser/scm-quick-open-service.js +73 -73
  49. package/lib/browser/scm-repository.d.ts +17 -17
  50. package/lib/browser/scm-repository.js +41 -41
  51. package/lib/browser/scm-service.d.ts +26 -26
  52. package/lib/browser/scm-service.js +108 -108
  53. package/lib/browser/scm-tree-label-provider.d.ts +7 -7
  54. package/lib/browser/scm-tree-label-provider.js +57 -57
  55. package/lib/browser/scm-tree-model.d.ts +74 -74
  56. package/lib/browser/scm-tree-model.js +348 -348
  57. package/lib/browser/scm-tree-widget.d.ts +201 -201
  58. package/lib/browser/scm-tree-widget.js +664 -664
  59. package/lib/browser/scm-widget.d.ts +40 -40
  60. package/lib/browser/scm-widget.js +218 -218
  61. package/package.json +6 -6
  62. package/src/browser/decorations/scm-decorations-service.ts +78 -78
  63. package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
  64. package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
  65. package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
  66. package/src/browser/dirty-diff/content-lines.ts +112 -112
  67. package/src/browser/dirty-diff/diff-computer.spec.ts +387 -387
  68. package/src/browser/dirty-diff/diff-computer.ts +129 -129
  69. package/src/browser/dirty-diff/dirty-diff-decorator.ts +107 -107
  70. package/src/browser/dirty-diff/dirty-diff-module.ts +24 -24
  71. package/src/browser/scm-amend-component.tsx +600 -600
  72. package/src/browser/scm-amend-widget.tsx +77 -77
  73. package/src/browser/scm-avatar-service.ts +27 -27
  74. package/src/browser/scm-commit-widget.tsx +215 -215
  75. package/src/browser/scm-context-key-service.ts +46 -46
  76. package/src/browser/scm-contribution.ts +361 -361
  77. package/src/browser/scm-frontend-module.ts +149 -149
  78. package/src/browser/scm-groups-tree-model.ts +78 -78
  79. package/src/browser/scm-input.ts +164 -164
  80. package/src/browser/scm-layout-migrations.ts +64 -64
  81. package/src/browser/scm-no-repository-widget.tsx +41 -41
  82. package/src/browser/scm-preferences.ts +63 -63
  83. package/src/browser/scm-provider.ts +89 -89
  84. package/src/browser/scm-quick-open-service.ts +48 -48
  85. package/src/browser/scm-repository.ts +52 -52
  86. package/src/browser/scm-service.ts +108 -108
  87. package/src/browser/scm-tree-label-provider.ts +44 -44
  88. package/src/browser/scm-tree-model.ts +405 -405
  89. package/src/browser/scm-tree-widget.tsx +809 -809
  90. package/src/browser/scm-widget.tsx +204 -204
  91. package/src/browser/style/dirty-diff-decorator.css +52 -52
  92. package/src/browser/style/dirty-diff.css +50 -50
  93. package/src/browser/style/index.css +267 -267
  94. package/src/browser/style/scm-amend-component.css +94 -94
  95. package/src/browser/style/scm.svg +4 -4
@@ -1,809 +1,809 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Arm 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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /* eslint-disable no-null/no-null, @typescript-eslint/no-explicit-any */
18
-
19
- import * as React from '@theia/core/shared/react';
20
- import { injectable, inject } from '@theia/core/shared/inversify';
21
- import URI from '@theia/core/lib/common/uri';
22
- import { isOSX } from '@theia/core/lib/common/os';
23
- import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable';
24
- import { TreeWidget, TreeNode, SelectableTreeNode, TreeModel, TreeProps, NodeProps, TREE_NODE_SEGMENT_CLASS, TREE_NODE_SEGMENT_GROW_CLASS } from '@theia/core/lib/browser/tree';
25
- import { ScmTreeModel, ScmFileChangeRootNode, ScmFileChangeGroupNode, ScmFileChangeFolderNode, ScmFileChangeNode } from './scm-tree-model';
26
- import { MenuModelRegistry, ActionMenuNode, CompoundMenuNode, MenuPath } from '@theia/core/lib/common/menu';
27
- import { ScmResource } from './scm-provider';
28
- import { CommandRegistry } from '@theia/core/lib/common/command';
29
- import { ContextMenuRenderer, LabelProvider, CorePreferences, DiffUris, ACTION_ITEM } from '@theia/core/lib/browser';
30
- import { ScmContextKeyService } from './scm-context-key-service';
31
- import { EditorWidget, EditorManager, DiffNavigatorProvider } from '@theia/editor/lib/browser';
32
- import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
33
- import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
34
- import { Decoration, DecorationsService } from '@theia/core/lib/browser/decorations-service';
35
- import { FileStat } from '@theia/filesystem/lib/common/files';
36
-
37
- @injectable()
38
- export class ScmTreeWidget extends TreeWidget {
39
-
40
- static ID = 'scm-resource-widget';
41
-
42
- static RESOURCE_GROUP_CONTEXT_MENU = ['RESOURCE_GROUP_CONTEXT_MENU'];
43
- static RESOURCE_GROUP_INLINE_MENU = ['RESOURCE_GROUP_CONTEXT_MENU', 'inline'];
44
-
45
- static RESOURCE_FOLDER_CONTEXT_MENU = ['RESOURCE_FOLDER_CONTEXT_MENU'];
46
- static RESOURCE_FOLDER_INLINE_MENU = ['RESOURCE_FOLDER_CONTEXT_MENU', 'inline'];
47
-
48
- static RESOURCE_CONTEXT_MENU = ['RESOURCE_CONTEXT_MENU'];
49
- static RESOURCE_INLINE_MENU = ['RESOURCE_CONTEXT_MENU', 'inline'];
50
-
51
- @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry;
52
- @inject(CommandRegistry) protected readonly commands: CommandRegistry;
53
- @inject(ScmContextKeyService) protected readonly contextKeys: ScmContextKeyService;
54
- @inject(EditorManager) protected readonly editorManager: EditorManager;
55
- @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider: DiffNavigatorProvider;
56
- @inject(IconThemeService) protected readonly iconThemeService: IconThemeService;
57
- @inject(DecorationsService) protected readonly decorationsService: DecorationsService;
58
- @inject(ColorRegistry) protected readonly colors: ColorRegistry;
59
-
60
- // TODO: Make TreeWidget generic to better type those fields.
61
- override readonly model: ScmTreeModel;
62
-
63
- constructor(
64
- @inject(TreeProps) props: TreeProps,
65
- @inject(TreeModel) treeModel: ScmTreeModel,
66
- @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer,
67
- ) {
68
- super(props, treeModel, contextMenuRenderer);
69
- this.id = ScmTreeWidget.ID;
70
- this.addClass('groups-outer-container');
71
- }
72
-
73
- set viewMode(id: 'tree' | 'list') {
74
- // Close the search box because the structure of the tree will change dramatically
75
- // and the search results will be out of date.
76
- this.searchBox.hide();
77
- this.model.viewMode = id;
78
- }
79
- get viewMode(): 'tree' | 'list' {
80
- return this.model.viewMode;
81
- }
82
-
83
- /**
84
- * Render the node given the tree node and node properties.
85
- * @param node the tree node.
86
- * @param props the node properties.
87
- */
88
- protected override renderNode(node: TreeNode, props: NodeProps): React.ReactNode {
89
- if (!TreeNode.isVisible(node)) {
90
- return undefined;
91
- }
92
-
93
- const attributes = this.createNodeAttributes(node, props);
94
- const label = this.labelProvider.getName(node);
95
- const searchHighlights = this.searchHighlights?.get(node.id);
96
- // The group nodes should not be subject to highlighting.
97
- const caption = (searchHighlights && !ScmFileChangeGroupNode.is(node)) ? this.toReactNode(label, searchHighlights) : label;
98
-
99
- if (ScmFileChangeGroupNode.is(node)) {
100
- const content = <ScmResourceGroupElement
101
- key={`${node.groupId}`}
102
- model={this.model}
103
- treeNode={node}
104
- renderExpansionToggle={() => this.renderExpansionToggle(node, props)}
105
- contextMenuRenderer={this.contextMenuRenderer}
106
- commands={this.commands}
107
- menus={this.menus}
108
- contextKeys={this.contextKeys}
109
- labelProvider={this.labelProvider}
110
- corePreferences={this.corePreferences}
111
- caption={caption}
112
- />;
113
-
114
- return React.createElement('div', attributes, content);
115
-
116
- }
117
- if (ScmFileChangeFolderNode.is(node)) {
118
- const content = <ScmResourceFolderElement
119
- key={String(node.sourceUri)}
120
- model={this.model}
121
- treeNode={node}
122
- sourceUri={node.sourceUri}
123
- renderExpansionToggle={() => this.renderExpansionToggle(node, props)}
124
- contextMenuRenderer={this.contextMenuRenderer}
125
- commands={this.commands}
126
- menus={this.menus}
127
- contextKeys={this.contextKeys}
128
- labelProvider={this.labelProvider}
129
- corePreferences={this.corePreferences}
130
- caption={caption}
131
- />;
132
-
133
- return React.createElement('div', attributes, content);
134
- }
135
- if (ScmFileChangeNode.is(node)) {
136
- const parentPath =
137
- (node.parent && ScmFileChangeFolderNode.is(node.parent))
138
- ? new URI(node.parent.sourceUri) : new URI(this.model.rootUri);
139
-
140
- const content = <ScmResourceComponent
141
- key={node.sourceUri}
142
- model={this.model}
143
- treeNode={node}
144
- contextMenuRenderer={this.contextMenuRenderer}
145
- commands={this.commands}
146
- menus={this.menus}
147
- contextKeys={this.contextKeys}
148
- labelProvider={this.labelProvider}
149
- corePreferences={this.corePreferences}
150
- caption={caption}
151
- {...{
152
- ...this.props,
153
- parentPath,
154
- sourceUri: node.sourceUri,
155
- decoration: this.decorationsService.getDecoration(new URI(node.sourceUri), true)[0],
156
- colors: this.colors,
157
- renderExpansionToggle: () => this.renderExpansionToggle(node, props),
158
- }}
159
- />;
160
- return React.createElement('div', attributes, content);
161
- }
162
- return super.renderNode(node, props);
163
- }
164
-
165
- protected override createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
166
- if (this.model.canTabToWidget()) {
167
- return {
168
- ...super.createContainerAttributes(),
169
- tabIndex: 0
170
- };
171
- }
172
- return super.createContainerAttributes();
173
- }
174
-
175
- /**
176
- * The ARROW_LEFT key controls both the movement around the file tree and also
177
- * the movement through the change chunks within a file.
178
- *
179
- * If the selected tree node is a folder then the ARROW_LEFT key behaves exactly
180
- * as it does in explorer. It collapses the tree node if the folder is expanded and
181
- * it moves the selection up to the parent folder if the folder is collapsed (no-op if no parent folder, as
182
- * group headers are not selectable). This behavior is the default behavior implemented
183
- * in the TreeWidget super class.
184
- *
185
- * If the selected tree node is a file then the ARROW_LEFT key moves up through the
186
- * change chunks within each file. If the selected chunk is the first chunk in the file
187
- * then the file selection is moved to the previous file (no-op if no previous file).
188
- *
189
- * Note that when cursoring through change chunks, the ARROW_LEFT key cannot be used to
190
- * move up through the parent folders of the file tree. If users want to do this, using
191
- * keys only, then they must press ARROW_UP repeatedly until the selected node is the folder
192
- * node and then press ARROW_LEFT.
193
- */
194
- protected override async handleLeft(event: KeyboardEvent): Promise<void> {
195
- if (this.model.selectedNodes.length === 1) {
196
- const selectedNode = this.model.selectedNodes[0];
197
- if (ScmFileChangeNode.is(selectedNode)) {
198
- const selectedResource = this.model.getResourceFromNode(selectedNode);
199
- if (!selectedResource) {
200
- return super.handleLeft(event);
201
- }
202
- const widget = await this.openResource(selectedResource);
203
-
204
- if (widget) {
205
- const diffNavigator = this.diffNavigatorProvider(widget.editor);
206
- if (diffNavigator.hasPrevious()) {
207
- diffNavigator.previous();
208
- } else {
209
- const previousNode = this.moveToPreviousFileNode();
210
- if (previousNode) {
211
- const previousResource = this.model.getResourceFromNode(previousNode);
212
- if (previousResource) {
213
- this.openResource(previousResource);
214
- }
215
- }
216
- }
217
- return;
218
- }
219
- }
220
- }
221
- return super.handleLeft(event);
222
- }
223
-
224
- /**
225
- * The ARROW_RIGHT key controls both the movement around the file tree and also
226
- * the movement through the change chunks within a file.
227
- *
228
- * If the selected tree node is a folder then the ARROW_RIGHT key behaves exactly
229
- * as it does in explorer. It expands the tree node if the folder is collapsed and
230
- * it moves the selection to the first child node if the folder is expanded.
231
- * This behavior is the default behavior implemented
232
- * in the TreeWidget super class.
233
- *
234
- * If the selected tree node is a file then the ARROW_RIGHT key moves down through the
235
- * change chunks within each file. If the selected chunk is the last chunk in the file
236
- * then the file selection is moved to the next file (no-op if no next file).
237
- */
238
- protected override async handleRight(event: KeyboardEvent): Promise<void> {
239
- if (this.model.selectedNodes.length === 0) {
240
- const firstNode = this.getFirstSelectableNode();
241
- // Selects the first visible resource as none are selected.
242
- if (!firstNode) {
243
- return;
244
- }
245
- this.model.selectNode(firstNode);
246
- return;
247
- }
248
- if (this.model.selectedNodes.length === 1) {
249
- const selectedNode = this.model.selectedNodes[0];
250
- if (ScmFileChangeNode.is(selectedNode)) {
251
- const selectedResource = this.model.getResourceFromNode(selectedNode);
252
- if (!selectedResource) {
253
- return super.handleRight(event);
254
- }
255
- const widget = await this.openResource(selectedResource);
256
-
257
- if (widget) {
258
- const diffNavigator = this.diffNavigatorProvider(widget.editor);
259
- if (diffNavigator.hasNext()) {
260
- diffNavigator.next();
261
- } else {
262
- const nextNode = this.moveToNextFileNode();
263
- if (nextNode) {
264
- const nextResource = this.model.getResourceFromNode(nextNode);
265
- if (nextResource) {
266
- this.openResource(nextResource);
267
- }
268
- }
269
- }
270
- }
271
- return;
272
- }
273
- }
274
- return super.handleRight(event);
275
- }
276
-
277
- protected override handleEnter(event: KeyboardEvent): void {
278
- if (this.model.selectedNodes.length === 1) {
279
- const selectedNode = this.model.selectedNodes[0];
280
- if (ScmFileChangeNode.is(selectedNode)) {
281
- const selectedResource = this.model.getResourceFromNode(selectedNode);
282
- if (selectedResource) {
283
- this.openResource(selectedResource);
284
- }
285
- return;
286
- }
287
- }
288
- super.handleEnter(event);
289
- }
290
-
291
- async goToPreviousChange(): Promise<void> {
292
- if (this.model.selectedNodes.length === 1) {
293
- const selectedNode = this.model.selectedNodes[0];
294
- if (ScmFileChangeNode.is(selectedNode)) {
295
- if (ScmFileChangeNode.is(selectedNode)) {
296
- const selectedResource = this.model.getResourceFromNode(selectedNode);
297
- if (!selectedResource) {
298
- return;
299
- }
300
- const widget = await this.openResource(selectedResource);
301
-
302
- if (widget) {
303
- const diffNavigator = this.diffNavigatorProvider(widget.editor);
304
- if (diffNavigator.hasPrevious()) {
305
- diffNavigator.previous();
306
- } else {
307
- const previousNode = this.moveToPreviousFileNode();
308
- if (previousNode) {
309
- const previousResource = this.model.getResourceFromNode(previousNode);
310
- if (previousResource) {
311
- this.openResource(previousResource);
312
- }
313
- }
314
- }
315
- }
316
- }
317
- }
318
- }
319
- }
320
-
321
- async goToNextChange(): Promise<void> {
322
- if (this.model.selectedNodes.length === 0) {
323
- const firstNode = this.getFirstSelectableNode();
324
- // Selects the first visible resource as none are selected.
325
- if (!firstNode) {
326
- return;
327
- }
328
- this.model.selectNode(firstNode);
329
- return;
330
- }
331
- if (this.model.selectedNodes.length === 1) {
332
- const selectedNode = this.model.selectedNodes[0];
333
- if (ScmFileChangeNode.is(selectedNode)) {
334
- const selectedResource = this.model.getResourceFromNode(selectedNode);
335
- if (!selectedResource) {
336
- return;
337
- }
338
- const widget = await this.openResource(selectedResource);
339
-
340
- if (widget) {
341
- const diffNavigator = this.diffNavigatorProvider(widget.editor);
342
- if (diffNavigator.hasNext()) {
343
- diffNavigator.next();
344
- } else {
345
- const nextNode = this.moveToNextFileNode();
346
- if (nextNode) {
347
- const nextResource = this.model.getResourceFromNode(nextNode);
348
- if (nextResource) {
349
- this.openResource(nextResource);
350
- }
351
- }
352
- }
353
- }
354
- }
355
- }
356
- }
357
-
358
- selectNodeByUri(uri: URI): void {
359
- for (const group of this.model.groups) {
360
- const sourceUri = new URI(uri.path.toString());
361
- const id = `${group.id}:${sourceUri.toString()}`;
362
- const node = this.model.getNode(id);
363
- if (SelectableTreeNode.is(node)) {
364
- this.model.selectNode(node);
365
- return;
366
- }
367
- }
368
- }
369
-
370
- protected getFirstSelectableNode(): SelectableTreeNode | undefined {
371
- if (this.model.root) {
372
- const root = this.model.root as ScmFileChangeRootNode;
373
- const groupNode = root.children[0];
374
- return groupNode.children[0];
375
- }
376
- }
377
-
378
- protected moveToPreviousFileNode(): ScmFileChangeNode | undefined {
379
- let previousNode = this.model.getPrevSelectableNode();
380
- while (previousNode) {
381
- if (ScmFileChangeNode.is(previousNode)) {
382
- this.model.selectNode(previousNode);
383
- return previousNode;
384
- }
385
- previousNode = this.model.getPrevSelectableNode(previousNode);
386
- };
387
- }
388
-
389
- protected moveToNextFileNode(): ScmFileChangeNode | undefined {
390
- let nextNode = this.model.getNextSelectableNode();
391
- while (nextNode) {
392
- if (ScmFileChangeNode.is(nextNode)) {
393
- this.model.selectNode(nextNode);
394
- return nextNode;
395
- }
396
- nextNode = this.model.getNextSelectableNode(nextNode);
397
- };
398
- }
399
-
400
- protected async openResource(resource: ScmResource): Promise<EditorWidget | undefined> {
401
- try {
402
- await resource.open();
403
- } catch (e) {
404
- console.error('Failed to open a SCM resource', e);
405
- return undefined;
406
- }
407
-
408
- let standaloneEditor: EditorWidget | undefined;
409
- const resourcePath = resource.sourceUri.path.toString();
410
-
411
- for (const widget of this.editorManager.all) {
412
- const resourceUri = widget.editor.document.uri;
413
- const editorResourcePath = new URI(resourceUri).path.toString();
414
- if (resourcePath === editorResourcePath) {
415
- if (widget.editor.uri.scheme === DiffUris.DIFF_SCHEME) {
416
- // prefer diff editor
417
- return widget;
418
- } else {
419
- standaloneEditor = widget;
420
- }
421
- }
422
- if (widget.editor.uri.scheme === DiffUris.DIFF_SCHEME
423
- && resourceUri === resource.sourceUri.toString()) {
424
- return widget;
425
- }
426
- }
427
- // fallback to standalone editor
428
- return standaloneEditor;
429
- }
430
-
431
- protected override getPaddingLeft(node: TreeNode, props: NodeProps): number {
432
- if (this.viewMode === 'list') {
433
- if (props.depth === 1) {
434
- return this.props.expansionTogglePadding;
435
- }
436
- }
437
- return super.getPaddingLeft(node, props);
438
- }
439
-
440
- protected override needsExpansionTogglePadding(node: TreeNode): boolean {
441
- const theme = this.iconThemeService.getDefinition(this.iconThemeService.current);
442
- if (theme && (theme.hidesExplorerArrows || (theme.hasFileIcons && !theme.hasFolderIcons))) {
443
- return false;
444
- }
445
- return super.needsExpansionTogglePadding(node);
446
- }
447
-
448
- }
449
-
450
- export namespace ScmTreeWidget {
451
- export namespace Styles {
452
- export const NO_SELECT = 'no-select';
453
- }
454
- // This is an 'abstract' base interface for all the element component props.
455
- export interface Props {
456
- treeNode: TreeNode;
457
- model: ScmTreeModel;
458
- commands: CommandRegistry;
459
- menus: MenuModelRegistry;
460
- contextKeys: ScmContextKeyService;
461
- labelProvider: LabelProvider;
462
- contextMenuRenderer: ContextMenuRenderer;
463
- corePreferences?: CorePreferences;
464
- caption: React.ReactNode;
465
- }
466
- }
467
-
468
- export abstract class ScmElement<P extends ScmElement.Props = ScmElement.Props> extends React.Component<P, ScmElement.State> {
469
-
470
- constructor(props: P) {
471
- super(props);
472
- this.state = {
473
- hover: false
474
- };
475
-
476
- const setState = this.setState.bind(this);
477
- this.setState = newState => {
478
- if (!this.toDisposeOnUnmount.disposed) {
479
- setState(newState);
480
- }
481
- };
482
- }
483
-
484
- protected readonly toDisposeOnUnmount = new DisposableCollection();
485
- override componentDidMount(): void {
486
- this.toDisposeOnUnmount.push(Disposable.create(() => { /* mark as mounted */ }));
487
- }
488
- override componentWillUnmount(): void {
489
- this.toDisposeOnUnmount.dispose();
490
- }
491
-
492
- protected detectHover = (element: HTMLElement | null) => {
493
- if (element) {
494
- window.requestAnimationFrame(() => {
495
- const hover = element.matches(':hover');
496
- this.setState({ hover });
497
- });
498
- }
499
- };
500
- protected showHover = () => this.setState({ hover: true });
501
- protected hideHover = () => this.setState({ hover: false });
502
-
503
- protected renderContextMenu = (event: React.MouseEvent<HTMLElement>) => {
504
- event.preventDefault();
505
- const { treeNode: node, contextMenuRenderer } = this.props;
506
- this.props.model.execInNodeContext(node, () => {
507
- contextMenuRenderer.render({
508
- menuPath: this.contextMenuPath,
509
- anchor: event.nativeEvent,
510
- args: this.contextMenuArgs
511
- });
512
- });
513
- };
514
-
515
- protected abstract get contextMenuPath(): MenuPath;
516
- protected abstract get contextMenuArgs(): any[];
517
-
518
- }
519
- export namespace ScmElement {
520
- export interface Props extends ScmTreeWidget.Props {
521
- renderExpansionToggle: () => React.ReactNode
522
- }
523
- export interface State {
524
- hover: boolean
525
- }
526
- }
527
-
528
- export class ScmResourceComponent extends ScmElement<ScmResourceComponent.Props> {
529
-
530
- override render(): JSX.Element | undefined {
531
- const { hover } = this.state;
532
- const { model, treeNode, colors, parentPath, sourceUri, decoration, labelProvider, commands, menus, contextKeys, caption } = this.props;
533
- const resourceUri = new URI(sourceUri);
534
-
535
- const icon = labelProvider.getIcon(resourceUri);
536
- const color = decoration && decoration.colorId ? `var(${colors.toCssVariableName(decoration.colorId)})` : '';
537
- const letter = decoration && decoration.letter || '';
538
- const tooltip = decoration && decoration.tooltip || '';
539
- const textDecoration = treeNode.decorations?.strikeThrough === true ? 'line-through' : 'normal';
540
- const relativePath = parentPath.relative(resourceUri.parent);
541
- const path = relativePath ? relativePath.fsPath() : labelProvider.getLongName(resourceUri.parent);
542
- const title = tooltip.length !== 0
543
- ? `${resourceUri.path.fsPath()} • ${tooltip}`
544
- : resourceUri.path.fsPath();
545
-
546
- return <div key={sourceUri}
547
- className={`scmItem ${TREE_NODE_SEGMENT_CLASS} ${TREE_NODE_SEGMENT_GROW_CLASS}`}
548
- onContextMenu={this.renderContextMenu}
549
- onMouseEnter={this.showHover}
550
- onMouseLeave={this.hideHover}
551
- ref={this.detectHover}
552
- title={title}
553
- onClick={this.handleClick}
554
- onDoubleClick={this.handleDoubleClick} >
555
- <span className={icon + ' file-icon'} />
556
- {this.props.renderExpansionToggle()}
557
- <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
558
- <span className='name' style={{ textDecoration }}>{caption}</span>
559
- <span className='path' style={{ textDecoration }}>{path}</span>
560
- </div>
561
- <ScmInlineActions {...{
562
- hover,
563
- menu: menus.getMenu(ScmTreeWidget.RESOURCE_INLINE_MENU),
564
- args: this.contextMenuArgs,
565
- commands,
566
- contextKeys,
567
- model,
568
- treeNode
569
- }}>
570
- <div title={tooltip} className='status' style={{ color }}>
571
- {letter}
572
- </div>
573
- </ScmInlineActions>
574
- </div >;
575
- }
576
-
577
- protected open = () => {
578
- const resource = this.props.model.getResourceFromNode(this.props.treeNode);
579
- if (resource) {
580
- resource.open();
581
- }
582
- };
583
-
584
- protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_CONTEXT_MENU;
585
- protected get contextMenuArgs(): any[] {
586
- if (!this.props.model.selectedNodes.some(node => ScmFileChangeNode.is(node) && node.sourceUri === this.props.sourceUri)) {
587
- // Clicked node is not in selection, so ignore selection and action on just clicked node
588
- return this.singleNodeArgs;
589
- } else {
590
- return this.props.model.getSelectionArgs(this.props.model.selectedNodes);
591
- }
592
- }
593
- protected get singleNodeArgs(): any[] {
594
- const selectedResource = this.props.model.getResourceFromNode(this.props.treeNode);
595
- if (selectedResource) {
596
- return [selectedResource];
597
- } else {
598
- // Repository status not yet available. Empty args disables the action.
599
- return [];
600
- }
601
- }
602
-
603
- protected hasCtrlCmdOrShiftMask(event: TreeWidget.ModifierAwareEvent): boolean {
604
- const { metaKey, ctrlKey, shiftKey } = event;
605
- return (isOSX && metaKey) || ctrlKey || shiftKey;
606
- }
607
-
608
- /**
609
- * Handle the single clicking of nodes present in the widget.
610
- */
611
- protected handleClick = (event: React.MouseEvent) => {
612
- if (!this.hasCtrlCmdOrShiftMask(event)) {
613
- // Determine the behavior based on the preference value.
614
- const isSingle = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'singleClick';
615
- if (isSingle) {
616
- this.open();
617
- }
618
- }
619
- };
620
-
621
- /**
622
- * Handle the double clicking of nodes present in the widget.
623
- */
624
- protected handleDoubleClick = () => {
625
- // Determine the behavior based on the preference value.
626
- const isDouble = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'doubleClick';
627
- // Nodes should only be opened through double clicking if the correct preference is set.
628
- if (isDouble) {
629
- this.open();
630
- }
631
- };
632
- }
633
- export namespace ScmResourceComponent {
634
- export interface Props extends ScmElement.Props {
635
- treeNode: ScmFileChangeNode;
636
- parentPath: URI;
637
- sourceUri: string;
638
- decoration: Decoration | undefined;
639
- colors: ColorRegistry;
640
- }
641
- }
642
-
643
- export class ScmResourceGroupElement extends ScmElement<ScmResourceGroupComponent.Props> {
644
-
645
- override render(): JSX.Element {
646
- const { hover } = this.state;
647
- const { model, treeNode, menus, commands, contextKeys, caption } = this.props;
648
- return <div className={`theia-header scm-theia-header ${TREE_NODE_SEGMENT_GROW_CLASS}`}
649
- onContextMenu={this.renderContextMenu}
650
- onMouseEnter={this.showHover}
651
- onMouseLeave={this.hideHover}
652
- ref={this.detectHover}>
653
- {this.props.renderExpansionToggle()}
654
- <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`}>{caption}</div>
655
- <ScmInlineActions {...{
656
- hover,
657
- args: this.contextMenuArgs,
658
- menu: menus.getMenu(ScmTreeWidget.RESOURCE_GROUP_INLINE_MENU),
659
- commands,
660
- contextKeys,
661
- model,
662
- treeNode
663
- }}>
664
- {this.renderChangeCount()}
665
- </ScmInlineActions>
666
- </div>;
667
- }
668
-
669
- protected renderChangeCount(): React.ReactNode {
670
- const group = this.props.model.getResourceGroupFromNode(this.props.treeNode);
671
- return <div className='notification-count-container scm-change-count'>
672
- <span className='notification-count'>{group ? group.resources.length : 0}</span>
673
- </div>;
674
- }
675
-
676
- protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_GROUP_CONTEXT_MENU;
677
- protected get contextMenuArgs(): any[] {
678
- const group = this.props.model.getResourceGroupFromNode(this.props.treeNode);
679
- if (group) {
680
- return [group];
681
- } else {
682
- // Repository status not yet available. Empty args disables the action.
683
- return [];
684
- }
685
- }
686
- }
687
- export namespace ScmResourceGroupComponent {
688
- export interface Props extends ScmElement.Props {
689
- treeNode: ScmFileChangeGroupNode;
690
- }
691
- }
692
-
693
- export class ScmResourceFolderElement extends ScmElement<ScmResourceFolderElement.Props> {
694
-
695
- override render(): JSX.Element {
696
- const { hover } = this.state;
697
- const { model, treeNode, sourceUri, labelProvider, commands, menus, contextKeys, caption } = this.props;
698
- const sourceFileStat = FileStat.dir(sourceUri);
699
- const icon = labelProvider.getIcon(sourceFileStat);
700
- const title = new URI(sourceUri).path.fsPath();
701
-
702
- return <div key={sourceUri}
703
- className={`scmItem ${TREE_NODE_SEGMENT_CLASS} ${TREE_NODE_SEGMENT_GROW_CLASS} ${ScmTreeWidget.Styles.NO_SELECT}`}
704
- title={title}
705
- onContextMenu={this.renderContextMenu}
706
- onMouseEnter={this.showHover}
707
- onMouseLeave={this.hideHover}
708
- ref={this.detectHover}
709
- >
710
- {this.props.renderExpansionToggle()}
711
- <span className={icon + ' file-icon'} />
712
- <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
713
- <span className='name'>{caption}</span>
714
- </div>
715
- <ScmInlineActions {...{
716
- hover,
717
- menu: menus.getMenu(ScmTreeWidget.RESOURCE_FOLDER_INLINE_MENU),
718
- args: this.contextMenuArgs,
719
- commands,
720
- contextKeys,
721
- model,
722
- treeNode
723
- }}>
724
- </ScmInlineActions>
725
- </div >;
726
-
727
- }
728
-
729
- protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_FOLDER_CONTEXT_MENU;
730
- protected get contextMenuArgs(): any[] {
731
- if (!this.props.model.selectedNodes.some(node => ScmFileChangeFolderNode.is(node) && node.sourceUri === this.props.sourceUri)) {
732
- // Clicked node is not in selection, so ignore selection and action on just clicked node
733
- return this.singleNodeArgs;
734
- } else {
735
- return this.props.model.getSelectionArgs(this.props.model.selectedNodes);
736
- }
737
- }
738
- protected get singleNodeArgs(): any[] {
739
- return this.props.model.getResourcesFromFolderNode(this.props.treeNode);
740
- }
741
-
742
- }
743
-
744
- export namespace ScmResourceFolderElement {
745
- export interface Props extends ScmElement.Props {
746
- treeNode: ScmFileChangeFolderNode;
747
- sourceUri: string;
748
- }
749
- }
750
-
751
- export class ScmInlineActions extends React.Component<ScmInlineActions.Props> {
752
- override render(): React.ReactNode {
753
- const { hover, menu, args, commands, model, treeNode, contextKeys, children } = this.props;
754
- return <div className='theia-scm-inline-actions-container'>
755
- <div className='theia-scm-inline-actions'>
756
- {hover && menu.children
757
- .map((node, index) => node instanceof ActionMenuNode && <ScmInlineAction key={index} {...{ node, args, commands, model, treeNode, contextKeys }} />)}
758
- </div>
759
- {children}
760
- </div>;
761
- }
762
- }
763
- export namespace ScmInlineActions {
764
- export interface Props {
765
- hover: boolean;
766
- menu: CompoundMenuNode;
767
- commands: CommandRegistry;
768
- model: ScmTreeModel;
769
- treeNode: TreeNode;
770
- contextKeys: ScmContextKeyService;
771
- args: any[];
772
- children?: React.ReactNode;
773
- }
774
- }
775
-
776
- export class ScmInlineAction extends React.Component<ScmInlineAction.Props> {
777
- override render(): React.ReactNode {
778
- const { node, model, treeNode, args, commands, contextKeys } = this.props;
779
-
780
- let isActive: boolean = false;
781
- model.execInNodeContext(treeNode, () => {
782
- isActive = contextKeys.match(node.when);
783
- });
784
-
785
- if (!commands.isVisible(node.command, ...args) || !isActive) {
786
- return false;
787
- }
788
- return <div className='theia-scm-inline-action'>
789
- <a className={`${node.icon} ${ACTION_ITEM}`} title={node.label} onClick={this.execute} />
790
- </div>;
791
- }
792
-
793
- protected execute = (event: React.MouseEvent) => {
794
- event.stopPropagation();
795
-
796
- const { commands, node, args } = this.props;
797
- commands.executeCommand(node.command, ...args);
798
- };
799
- }
800
- export namespace ScmInlineAction {
801
- export interface Props {
802
- node: ActionMenuNode;
803
- commands: CommandRegistry;
804
- model: ScmTreeModel;
805
- treeNode: TreeNode;
806
- contextKeys: ScmContextKeyService;
807
- args: any[];
808
- }
809
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 Arm 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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /* eslint-disable no-null/no-null, @typescript-eslint/no-explicit-any */
18
+
19
+ import * as React from '@theia/core/shared/react';
20
+ import { injectable, inject } from '@theia/core/shared/inversify';
21
+ import URI from '@theia/core/lib/common/uri';
22
+ import { isOSX } from '@theia/core/lib/common/os';
23
+ import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable';
24
+ import { TreeWidget, TreeNode, SelectableTreeNode, TreeModel, TreeProps, NodeProps, TREE_NODE_SEGMENT_CLASS, TREE_NODE_SEGMENT_GROW_CLASS } from '@theia/core/lib/browser/tree';
25
+ import { ScmTreeModel, ScmFileChangeRootNode, ScmFileChangeGroupNode, ScmFileChangeFolderNode, ScmFileChangeNode } from './scm-tree-model';
26
+ import { MenuModelRegistry, ActionMenuNode, CompoundMenuNode, MenuPath } from '@theia/core/lib/common/menu';
27
+ import { ScmResource } from './scm-provider';
28
+ import { CommandRegistry } from '@theia/core/lib/common/command';
29
+ import { ContextMenuRenderer, LabelProvider, CorePreferences, DiffUris, ACTION_ITEM } from '@theia/core/lib/browser';
30
+ import { ScmContextKeyService } from './scm-context-key-service';
31
+ import { EditorWidget, EditorManager, DiffNavigatorProvider } from '@theia/editor/lib/browser';
32
+ import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
33
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
34
+ import { Decoration, DecorationsService } from '@theia/core/lib/browser/decorations-service';
35
+ import { FileStat } from '@theia/filesystem/lib/common/files';
36
+
37
+ @injectable()
38
+ export class ScmTreeWidget extends TreeWidget {
39
+
40
+ static ID = 'scm-resource-widget';
41
+
42
+ static RESOURCE_GROUP_CONTEXT_MENU = ['RESOURCE_GROUP_CONTEXT_MENU'];
43
+ static RESOURCE_GROUP_INLINE_MENU = ['RESOURCE_GROUP_CONTEXT_MENU', 'inline'];
44
+
45
+ static RESOURCE_FOLDER_CONTEXT_MENU = ['RESOURCE_FOLDER_CONTEXT_MENU'];
46
+ static RESOURCE_FOLDER_INLINE_MENU = ['RESOURCE_FOLDER_CONTEXT_MENU', 'inline'];
47
+
48
+ static RESOURCE_CONTEXT_MENU = ['RESOURCE_CONTEXT_MENU'];
49
+ static RESOURCE_INLINE_MENU = ['RESOURCE_CONTEXT_MENU', 'inline'];
50
+
51
+ @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry;
52
+ @inject(CommandRegistry) protected readonly commands: CommandRegistry;
53
+ @inject(ScmContextKeyService) protected readonly contextKeys: ScmContextKeyService;
54
+ @inject(EditorManager) protected readonly editorManager: EditorManager;
55
+ @inject(DiffNavigatorProvider) protected readonly diffNavigatorProvider: DiffNavigatorProvider;
56
+ @inject(IconThemeService) protected readonly iconThemeService: IconThemeService;
57
+ @inject(DecorationsService) protected readonly decorationsService: DecorationsService;
58
+ @inject(ColorRegistry) protected readonly colors: ColorRegistry;
59
+
60
+ // TODO: Make TreeWidget generic to better type those fields.
61
+ override readonly model: ScmTreeModel;
62
+
63
+ constructor(
64
+ @inject(TreeProps) props: TreeProps,
65
+ @inject(TreeModel) treeModel: ScmTreeModel,
66
+ @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer,
67
+ ) {
68
+ super(props, treeModel, contextMenuRenderer);
69
+ this.id = ScmTreeWidget.ID;
70
+ this.addClass('groups-outer-container');
71
+ }
72
+
73
+ set viewMode(id: 'tree' | 'list') {
74
+ // Close the search box because the structure of the tree will change dramatically
75
+ // and the search results will be out of date.
76
+ this.searchBox.hide();
77
+ this.model.viewMode = id;
78
+ }
79
+ get viewMode(): 'tree' | 'list' {
80
+ return this.model.viewMode;
81
+ }
82
+
83
+ /**
84
+ * Render the node given the tree node and node properties.
85
+ * @param node the tree node.
86
+ * @param props the node properties.
87
+ */
88
+ protected override renderNode(node: TreeNode, props: NodeProps): React.ReactNode {
89
+ if (!TreeNode.isVisible(node)) {
90
+ return undefined;
91
+ }
92
+
93
+ const attributes = this.createNodeAttributes(node, props);
94
+ const label = this.labelProvider.getName(node);
95
+ const searchHighlights = this.searchHighlights?.get(node.id);
96
+ // The group nodes should not be subject to highlighting.
97
+ const caption = (searchHighlights && !ScmFileChangeGroupNode.is(node)) ? this.toReactNode(label, searchHighlights) : label;
98
+
99
+ if (ScmFileChangeGroupNode.is(node)) {
100
+ const content = <ScmResourceGroupElement
101
+ key={`${node.groupId}`}
102
+ model={this.model}
103
+ treeNode={node}
104
+ renderExpansionToggle={() => this.renderExpansionToggle(node, props)}
105
+ contextMenuRenderer={this.contextMenuRenderer}
106
+ commands={this.commands}
107
+ menus={this.menus}
108
+ contextKeys={this.contextKeys}
109
+ labelProvider={this.labelProvider}
110
+ corePreferences={this.corePreferences}
111
+ caption={caption}
112
+ />;
113
+
114
+ return React.createElement('div', attributes, content);
115
+
116
+ }
117
+ if (ScmFileChangeFolderNode.is(node)) {
118
+ const content = <ScmResourceFolderElement
119
+ key={String(node.sourceUri)}
120
+ model={this.model}
121
+ treeNode={node}
122
+ sourceUri={node.sourceUri}
123
+ renderExpansionToggle={() => this.renderExpansionToggle(node, props)}
124
+ contextMenuRenderer={this.contextMenuRenderer}
125
+ commands={this.commands}
126
+ menus={this.menus}
127
+ contextKeys={this.contextKeys}
128
+ labelProvider={this.labelProvider}
129
+ corePreferences={this.corePreferences}
130
+ caption={caption}
131
+ />;
132
+
133
+ return React.createElement('div', attributes, content);
134
+ }
135
+ if (ScmFileChangeNode.is(node)) {
136
+ const parentPath =
137
+ (node.parent && ScmFileChangeFolderNode.is(node.parent))
138
+ ? new URI(node.parent.sourceUri) : new URI(this.model.rootUri);
139
+
140
+ const content = <ScmResourceComponent
141
+ key={node.sourceUri}
142
+ model={this.model}
143
+ treeNode={node}
144
+ contextMenuRenderer={this.contextMenuRenderer}
145
+ commands={this.commands}
146
+ menus={this.menus}
147
+ contextKeys={this.contextKeys}
148
+ labelProvider={this.labelProvider}
149
+ corePreferences={this.corePreferences}
150
+ caption={caption}
151
+ {...{
152
+ ...this.props,
153
+ parentPath,
154
+ sourceUri: node.sourceUri,
155
+ decoration: this.decorationsService.getDecoration(new URI(node.sourceUri), true)[0],
156
+ colors: this.colors,
157
+ renderExpansionToggle: () => this.renderExpansionToggle(node, props),
158
+ }}
159
+ />;
160
+ return React.createElement('div', attributes, content);
161
+ }
162
+ return super.renderNode(node, props);
163
+ }
164
+
165
+ protected override createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
166
+ if (this.model.canTabToWidget()) {
167
+ return {
168
+ ...super.createContainerAttributes(),
169
+ tabIndex: 0
170
+ };
171
+ }
172
+ return super.createContainerAttributes();
173
+ }
174
+
175
+ /**
176
+ * The ARROW_LEFT key controls both the movement around the file tree and also
177
+ * the movement through the change chunks within a file.
178
+ *
179
+ * If the selected tree node is a folder then the ARROW_LEFT key behaves exactly
180
+ * as it does in explorer. It collapses the tree node if the folder is expanded and
181
+ * it moves the selection up to the parent folder if the folder is collapsed (no-op if no parent folder, as
182
+ * group headers are not selectable). This behavior is the default behavior implemented
183
+ * in the TreeWidget super class.
184
+ *
185
+ * If the selected tree node is a file then the ARROW_LEFT key moves up through the
186
+ * change chunks within each file. If the selected chunk is the first chunk in the file
187
+ * then the file selection is moved to the previous file (no-op if no previous file).
188
+ *
189
+ * Note that when cursoring through change chunks, the ARROW_LEFT key cannot be used to
190
+ * move up through the parent folders of the file tree. If users want to do this, using
191
+ * keys only, then they must press ARROW_UP repeatedly until the selected node is the folder
192
+ * node and then press ARROW_LEFT.
193
+ */
194
+ protected override async handleLeft(event: KeyboardEvent): Promise<void> {
195
+ if (this.model.selectedNodes.length === 1) {
196
+ const selectedNode = this.model.selectedNodes[0];
197
+ if (ScmFileChangeNode.is(selectedNode)) {
198
+ const selectedResource = this.model.getResourceFromNode(selectedNode);
199
+ if (!selectedResource) {
200
+ return super.handleLeft(event);
201
+ }
202
+ const widget = await this.openResource(selectedResource);
203
+
204
+ if (widget) {
205
+ const diffNavigator = this.diffNavigatorProvider(widget.editor);
206
+ if (diffNavigator.hasPrevious()) {
207
+ diffNavigator.previous();
208
+ } else {
209
+ const previousNode = this.moveToPreviousFileNode();
210
+ if (previousNode) {
211
+ const previousResource = this.model.getResourceFromNode(previousNode);
212
+ if (previousResource) {
213
+ this.openResource(previousResource);
214
+ }
215
+ }
216
+ }
217
+ return;
218
+ }
219
+ }
220
+ }
221
+ return super.handleLeft(event);
222
+ }
223
+
224
+ /**
225
+ * The ARROW_RIGHT key controls both the movement around the file tree and also
226
+ * the movement through the change chunks within a file.
227
+ *
228
+ * If the selected tree node is a folder then the ARROW_RIGHT key behaves exactly
229
+ * as it does in explorer. It expands the tree node if the folder is collapsed and
230
+ * it moves the selection to the first child node if the folder is expanded.
231
+ * This behavior is the default behavior implemented
232
+ * in the TreeWidget super class.
233
+ *
234
+ * If the selected tree node is a file then the ARROW_RIGHT key moves down through the
235
+ * change chunks within each file. If the selected chunk is the last chunk in the file
236
+ * then the file selection is moved to the next file (no-op if no next file).
237
+ */
238
+ protected override async handleRight(event: KeyboardEvent): Promise<void> {
239
+ if (this.model.selectedNodes.length === 0) {
240
+ const firstNode = this.getFirstSelectableNode();
241
+ // Selects the first visible resource as none are selected.
242
+ if (!firstNode) {
243
+ return;
244
+ }
245
+ this.model.selectNode(firstNode);
246
+ return;
247
+ }
248
+ if (this.model.selectedNodes.length === 1) {
249
+ const selectedNode = this.model.selectedNodes[0];
250
+ if (ScmFileChangeNode.is(selectedNode)) {
251
+ const selectedResource = this.model.getResourceFromNode(selectedNode);
252
+ if (!selectedResource) {
253
+ return super.handleRight(event);
254
+ }
255
+ const widget = await this.openResource(selectedResource);
256
+
257
+ if (widget) {
258
+ const diffNavigator = this.diffNavigatorProvider(widget.editor);
259
+ if (diffNavigator.hasNext()) {
260
+ diffNavigator.next();
261
+ } else {
262
+ const nextNode = this.moveToNextFileNode();
263
+ if (nextNode) {
264
+ const nextResource = this.model.getResourceFromNode(nextNode);
265
+ if (nextResource) {
266
+ this.openResource(nextResource);
267
+ }
268
+ }
269
+ }
270
+ }
271
+ return;
272
+ }
273
+ }
274
+ return super.handleRight(event);
275
+ }
276
+
277
+ protected override handleEnter(event: KeyboardEvent): void {
278
+ if (this.model.selectedNodes.length === 1) {
279
+ const selectedNode = this.model.selectedNodes[0];
280
+ if (ScmFileChangeNode.is(selectedNode)) {
281
+ const selectedResource = this.model.getResourceFromNode(selectedNode);
282
+ if (selectedResource) {
283
+ this.openResource(selectedResource);
284
+ }
285
+ return;
286
+ }
287
+ }
288
+ super.handleEnter(event);
289
+ }
290
+
291
+ async goToPreviousChange(): Promise<void> {
292
+ if (this.model.selectedNodes.length === 1) {
293
+ const selectedNode = this.model.selectedNodes[0];
294
+ if (ScmFileChangeNode.is(selectedNode)) {
295
+ if (ScmFileChangeNode.is(selectedNode)) {
296
+ const selectedResource = this.model.getResourceFromNode(selectedNode);
297
+ if (!selectedResource) {
298
+ return;
299
+ }
300
+ const widget = await this.openResource(selectedResource);
301
+
302
+ if (widget) {
303
+ const diffNavigator = this.diffNavigatorProvider(widget.editor);
304
+ if (diffNavigator.hasPrevious()) {
305
+ diffNavigator.previous();
306
+ } else {
307
+ const previousNode = this.moveToPreviousFileNode();
308
+ if (previousNode) {
309
+ const previousResource = this.model.getResourceFromNode(previousNode);
310
+ if (previousResource) {
311
+ this.openResource(previousResource);
312
+ }
313
+ }
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ }
320
+
321
+ async goToNextChange(): Promise<void> {
322
+ if (this.model.selectedNodes.length === 0) {
323
+ const firstNode = this.getFirstSelectableNode();
324
+ // Selects the first visible resource as none are selected.
325
+ if (!firstNode) {
326
+ return;
327
+ }
328
+ this.model.selectNode(firstNode);
329
+ return;
330
+ }
331
+ if (this.model.selectedNodes.length === 1) {
332
+ const selectedNode = this.model.selectedNodes[0];
333
+ if (ScmFileChangeNode.is(selectedNode)) {
334
+ const selectedResource = this.model.getResourceFromNode(selectedNode);
335
+ if (!selectedResource) {
336
+ return;
337
+ }
338
+ const widget = await this.openResource(selectedResource);
339
+
340
+ if (widget) {
341
+ const diffNavigator = this.diffNavigatorProvider(widget.editor);
342
+ if (diffNavigator.hasNext()) {
343
+ diffNavigator.next();
344
+ } else {
345
+ const nextNode = this.moveToNextFileNode();
346
+ if (nextNode) {
347
+ const nextResource = this.model.getResourceFromNode(nextNode);
348
+ if (nextResource) {
349
+ this.openResource(nextResource);
350
+ }
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+ }
357
+
358
+ selectNodeByUri(uri: URI): void {
359
+ for (const group of this.model.groups) {
360
+ const sourceUri = new URI(uri.path.toString());
361
+ const id = `${group.id}:${sourceUri.toString()}`;
362
+ const node = this.model.getNode(id);
363
+ if (SelectableTreeNode.is(node)) {
364
+ this.model.selectNode(node);
365
+ return;
366
+ }
367
+ }
368
+ }
369
+
370
+ protected getFirstSelectableNode(): SelectableTreeNode | undefined {
371
+ if (this.model.root) {
372
+ const root = this.model.root as ScmFileChangeRootNode;
373
+ const groupNode = root.children[0];
374
+ return groupNode.children[0];
375
+ }
376
+ }
377
+
378
+ protected moveToPreviousFileNode(): ScmFileChangeNode | undefined {
379
+ let previousNode = this.model.getPrevSelectableNode();
380
+ while (previousNode) {
381
+ if (ScmFileChangeNode.is(previousNode)) {
382
+ this.model.selectNode(previousNode);
383
+ return previousNode;
384
+ }
385
+ previousNode = this.model.getPrevSelectableNode(previousNode);
386
+ };
387
+ }
388
+
389
+ protected moveToNextFileNode(): ScmFileChangeNode | undefined {
390
+ let nextNode = this.model.getNextSelectableNode();
391
+ while (nextNode) {
392
+ if (ScmFileChangeNode.is(nextNode)) {
393
+ this.model.selectNode(nextNode);
394
+ return nextNode;
395
+ }
396
+ nextNode = this.model.getNextSelectableNode(nextNode);
397
+ };
398
+ }
399
+
400
+ protected async openResource(resource: ScmResource): Promise<EditorWidget | undefined> {
401
+ try {
402
+ await resource.open();
403
+ } catch (e) {
404
+ console.error('Failed to open a SCM resource', e);
405
+ return undefined;
406
+ }
407
+
408
+ let standaloneEditor: EditorWidget | undefined;
409
+ const resourcePath = resource.sourceUri.path.toString();
410
+
411
+ for (const widget of this.editorManager.all) {
412
+ const resourceUri = widget.editor.document.uri;
413
+ const editorResourcePath = new URI(resourceUri).path.toString();
414
+ if (resourcePath === editorResourcePath) {
415
+ if (widget.editor.uri.scheme === DiffUris.DIFF_SCHEME) {
416
+ // prefer diff editor
417
+ return widget;
418
+ } else {
419
+ standaloneEditor = widget;
420
+ }
421
+ }
422
+ if (widget.editor.uri.scheme === DiffUris.DIFF_SCHEME
423
+ && resourceUri === resource.sourceUri.toString()) {
424
+ return widget;
425
+ }
426
+ }
427
+ // fallback to standalone editor
428
+ return standaloneEditor;
429
+ }
430
+
431
+ protected override getPaddingLeft(node: TreeNode, props: NodeProps): number {
432
+ if (this.viewMode === 'list') {
433
+ if (props.depth === 1) {
434
+ return this.props.expansionTogglePadding;
435
+ }
436
+ }
437
+ return super.getPaddingLeft(node, props);
438
+ }
439
+
440
+ protected override needsExpansionTogglePadding(node: TreeNode): boolean {
441
+ const theme = this.iconThemeService.getDefinition(this.iconThemeService.current);
442
+ if (theme && (theme.hidesExplorerArrows || (theme.hasFileIcons && !theme.hasFolderIcons))) {
443
+ return false;
444
+ }
445
+ return super.needsExpansionTogglePadding(node);
446
+ }
447
+
448
+ }
449
+
450
+ export namespace ScmTreeWidget {
451
+ export namespace Styles {
452
+ export const NO_SELECT = 'no-select';
453
+ }
454
+ // This is an 'abstract' base interface for all the element component props.
455
+ export interface Props {
456
+ treeNode: TreeNode;
457
+ model: ScmTreeModel;
458
+ commands: CommandRegistry;
459
+ menus: MenuModelRegistry;
460
+ contextKeys: ScmContextKeyService;
461
+ labelProvider: LabelProvider;
462
+ contextMenuRenderer: ContextMenuRenderer;
463
+ corePreferences?: CorePreferences;
464
+ caption: React.ReactNode;
465
+ }
466
+ }
467
+
468
+ export abstract class ScmElement<P extends ScmElement.Props = ScmElement.Props> extends React.Component<P, ScmElement.State> {
469
+
470
+ constructor(props: P) {
471
+ super(props);
472
+ this.state = {
473
+ hover: false
474
+ };
475
+
476
+ const setState = this.setState.bind(this);
477
+ this.setState = newState => {
478
+ if (!this.toDisposeOnUnmount.disposed) {
479
+ setState(newState);
480
+ }
481
+ };
482
+ }
483
+
484
+ protected readonly toDisposeOnUnmount = new DisposableCollection();
485
+ override componentDidMount(): void {
486
+ this.toDisposeOnUnmount.push(Disposable.create(() => { /* mark as mounted */ }));
487
+ }
488
+ override componentWillUnmount(): void {
489
+ this.toDisposeOnUnmount.dispose();
490
+ }
491
+
492
+ protected detectHover = (element: HTMLElement | null) => {
493
+ if (element) {
494
+ window.requestAnimationFrame(() => {
495
+ const hover = element.matches(':hover');
496
+ this.setState({ hover });
497
+ });
498
+ }
499
+ };
500
+ protected showHover = () => this.setState({ hover: true });
501
+ protected hideHover = () => this.setState({ hover: false });
502
+
503
+ protected renderContextMenu = (event: React.MouseEvent<HTMLElement>) => {
504
+ event.preventDefault();
505
+ const { treeNode: node, contextMenuRenderer } = this.props;
506
+ this.props.model.execInNodeContext(node, () => {
507
+ contextMenuRenderer.render({
508
+ menuPath: this.contextMenuPath,
509
+ anchor: event.nativeEvent,
510
+ args: this.contextMenuArgs
511
+ });
512
+ });
513
+ };
514
+
515
+ protected abstract get contextMenuPath(): MenuPath;
516
+ protected abstract get contextMenuArgs(): any[];
517
+
518
+ }
519
+ export namespace ScmElement {
520
+ export interface Props extends ScmTreeWidget.Props {
521
+ renderExpansionToggle: () => React.ReactNode
522
+ }
523
+ export interface State {
524
+ hover: boolean
525
+ }
526
+ }
527
+
528
+ export class ScmResourceComponent extends ScmElement<ScmResourceComponent.Props> {
529
+
530
+ override render(): JSX.Element | undefined {
531
+ const { hover } = this.state;
532
+ const { model, treeNode, colors, parentPath, sourceUri, decoration, labelProvider, commands, menus, contextKeys, caption } = this.props;
533
+ const resourceUri = new URI(sourceUri);
534
+
535
+ const icon = labelProvider.getIcon(resourceUri);
536
+ const color = decoration && decoration.colorId ? `var(${colors.toCssVariableName(decoration.colorId)})` : '';
537
+ const letter = decoration && decoration.letter || '';
538
+ const tooltip = decoration && decoration.tooltip || '';
539
+ const textDecoration = treeNode.decorations?.strikeThrough === true ? 'line-through' : 'normal';
540
+ const relativePath = parentPath.relative(resourceUri.parent);
541
+ const path = relativePath ? relativePath.fsPath() : labelProvider.getLongName(resourceUri.parent);
542
+ const title = tooltip.length !== 0
543
+ ? `${resourceUri.path.fsPath()} • ${tooltip}`
544
+ : resourceUri.path.fsPath();
545
+
546
+ return <div key={sourceUri}
547
+ className={`scmItem ${TREE_NODE_SEGMENT_CLASS} ${TREE_NODE_SEGMENT_GROW_CLASS}`}
548
+ onContextMenu={this.renderContextMenu}
549
+ onMouseEnter={this.showHover}
550
+ onMouseLeave={this.hideHover}
551
+ ref={this.detectHover}
552
+ title={title}
553
+ onClick={this.handleClick}
554
+ onDoubleClick={this.handleDoubleClick} >
555
+ <span className={icon + ' file-icon'} />
556
+ {this.props.renderExpansionToggle()}
557
+ <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
558
+ <span className='name' style={{ textDecoration }}>{caption}</span>
559
+ <span className='path' style={{ textDecoration }}>{path}</span>
560
+ </div>
561
+ <ScmInlineActions {...{
562
+ hover,
563
+ menu: menus.getMenu(ScmTreeWidget.RESOURCE_INLINE_MENU),
564
+ args: this.contextMenuArgs,
565
+ commands,
566
+ contextKeys,
567
+ model,
568
+ treeNode
569
+ }}>
570
+ <div title={tooltip} className='status' style={{ color }}>
571
+ {letter}
572
+ </div>
573
+ </ScmInlineActions>
574
+ </div >;
575
+ }
576
+
577
+ protected open = () => {
578
+ const resource = this.props.model.getResourceFromNode(this.props.treeNode);
579
+ if (resource) {
580
+ resource.open();
581
+ }
582
+ };
583
+
584
+ protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_CONTEXT_MENU;
585
+ protected get contextMenuArgs(): any[] {
586
+ if (!this.props.model.selectedNodes.some(node => ScmFileChangeNode.is(node) && node.sourceUri === this.props.sourceUri)) {
587
+ // Clicked node is not in selection, so ignore selection and action on just clicked node
588
+ return this.singleNodeArgs;
589
+ } else {
590
+ return this.props.model.getSelectionArgs(this.props.model.selectedNodes);
591
+ }
592
+ }
593
+ protected get singleNodeArgs(): any[] {
594
+ const selectedResource = this.props.model.getResourceFromNode(this.props.treeNode);
595
+ if (selectedResource) {
596
+ return [selectedResource];
597
+ } else {
598
+ // Repository status not yet available. Empty args disables the action.
599
+ return [];
600
+ }
601
+ }
602
+
603
+ protected hasCtrlCmdOrShiftMask(event: TreeWidget.ModifierAwareEvent): boolean {
604
+ const { metaKey, ctrlKey, shiftKey } = event;
605
+ return (isOSX && metaKey) || ctrlKey || shiftKey;
606
+ }
607
+
608
+ /**
609
+ * Handle the single clicking of nodes present in the widget.
610
+ */
611
+ protected handleClick = (event: React.MouseEvent) => {
612
+ if (!this.hasCtrlCmdOrShiftMask(event)) {
613
+ // Determine the behavior based on the preference value.
614
+ const isSingle = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'singleClick';
615
+ if (isSingle) {
616
+ this.open();
617
+ }
618
+ }
619
+ };
620
+
621
+ /**
622
+ * Handle the double clicking of nodes present in the widget.
623
+ */
624
+ protected handleDoubleClick = () => {
625
+ // Determine the behavior based on the preference value.
626
+ const isDouble = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'doubleClick';
627
+ // Nodes should only be opened through double clicking if the correct preference is set.
628
+ if (isDouble) {
629
+ this.open();
630
+ }
631
+ };
632
+ }
633
+ export namespace ScmResourceComponent {
634
+ export interface Props extends ScmElement.Props {
635
+ treeNode: ScmFileChangeNode;
636
+ parentPath: URI;
637
+ sourceUri: string;
638
+ decoration: Decoration | undefined;
639
+ colors: ColorRegistry;
640
+ }
641
+ }
642
+
643
+ export class ScmResourceGroupElement extends ScmElement<ScmResourceGroupComponent.Props> {
644
+
645
+ override render(): JSX.Element {
646
+ const { hover } = this.state;
647
+ const { model, treeNode, menus, commands, contextKeys, caption } = this.props;
648
+ return <div className={`theia-header scm-theia-header ${TREE_NODE_SEGMENT_GROW_CLASS}`}
649
+ onContextMenu={this.renderContextMenu}
650
+ onMouseEnter={this.showHover}
651
+ onMouseLeave={this.hideHover}
652
+ ref={this.detectHover}>
653
+ {this.props.renderExpansionToggle()}
654
+ <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`}>{caption}</div>
655
+ <ScmInlineActions {...{
656
+ hover,
657
+ args: this.contextMenuArgs,
658
+ menu: menus.getMenu(ScmTreeWidget.RESOURCE_GROUP_INLINE_MENU),
659
+ commands,
660
+ contextKeys,
661
+ model,
662
+ treeNode
663
+ }}>
664
+ {this.renderChangeCount()}
665
+ </ScmInlineActions>
666
+ </div>;
667
+ }
668
+
669
+ protected renderChangeCount(): React.ReactNode {
670
+ const group = this.props.model.getResourceGroupFromNode(this.props.treeNode);
671
+ return <div className='notification-count-container scm-change-count'>
672
+ <span className='notification-count'>{group ? group.resources.length : 0}</span>
673
+ </div>;
674
+ }
675
+
676
+ protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_GROUP_CONTEXT_MENU;
677
+ protected get contextMenuArgs(): any[] {
678
+ const group = this.props.model.getResourceGroupFromNode(this.props.treeNode);
679
+ if (group) {
680
+ return [group];
681
+ } else {
682
+ // Repository status not yet available. Empty args disables the action.
683
+ return [];
684
+ }
685
+ }
686
+ }
687
+ export namespace ScmResourceGroupComponent {
688
+ export interface Props extends ScmElement.Props {
689
+ treeNode: ScmFileChangeGroupNode;
690
+ }
691
+ }
692
+
693
+ export class ScmResourceFolderElement extends ScmElement<ScmResourceFolderElement.Props> {
694
+
695
+ override render(): JSX.Element {
696
+ const { hover } = this.state;
697
+ const { model, treeNode, sourceUri, labelProvider, commands, menus, contextKeys, caption } = this.props;
698
+ const sourceFileStat = FileStat.dir(sourceUri);
699
+ const icon = labelProvider.getIcon(sourceFileStat);
700
+ const title = new URI(sourceUri).path.fsPath();
701
+
702
+ return <div key={sourceUri}
703
+ className={`scmItem ${TREE_NODE_SEGMENT_CLASS} ${TREE_NODE_SEGMENT_GROW_CLASS} ${ScmTreeWidget.Styles.NO_SELECT}`}
704
+ title={title}
705
+ onContextMenu={this.renderContextMenu}
706
+ onMouseEnter={this.showHover}
707
+ onMouseLeave={this.hideHover}
708
+ ref={this.detectHover}
709
+ >
710
+ {this.props.renderExpansionToggle()}
711
+ <span className={icon + ' file-icon'} />
712
+ <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
713
+ <span className='name'>{caption}</span>
714
+ </div>
715
+ <ScmInlineActions {...{
716
+ hover,
717
+ menu: menus.getMenu(ScmTreeWidget.RESOURCE_FOLDER_INLINE_MENU),
718
+ args: this.contextMenuArgs,
719
+ commands,
720
+ contextKeys,
721
+ model,
722
+ treeNode
723
+ }}>
724
+ </ScmInlineActions>
725
+ </div >;
726
+
727
+ }
728
+
729
+ protected readonly contextMenuPath = ScmTreeWidget.RESOURCE_FOLDER_CONTEXT_MENU;
730
+ protected get contextMenuArgs(): any[] {
731
+ if (!this.props.model.selectedNodes.some(node => ScmFileChangeFolderNode.is(node) && node.sourceUri === this.props.sourceUri)) {
732
+ // Clicked node is not in selection, so ignore selection and action on just clicked node
733
+ return this.singleNodeArgs;
734
+ } else {
735
+ return this.props.model.getSelectionArgs(this.props.model.selectedNodes);
736
+ }
737
+ }
738
+ protected get singleNodeArgs(): any[] {
739
+ return this.props.model.getResourcesFromFolderNode(this.props.treeNode);
740
+ }
741
+
742
+ }
743
+
744
+ export namespace ScmResourceFolderElement {
745
+ export interface Props extends ScmElement.Props {
746
+ treeNode: ScmFileChangeFolderNode;
747
+ sourceUri: string;
748
+ }
749
+ }
750
+
751
+ export class ScmInlineActions extends React.Component<ScmInlineActions.Props> {
752
+ override render(): React.ReactNode {
753
+ const { hover, menu, args, commands, model, treeNode, contextKeys, children } = this.props;
754
+ return <div className='theia-scm-inline-actions-container'>
755
+ <div className='theia-scm-inline-actions'>
756
+ {hover && menu.children
757
+ .map((node, index) => node instanceof ActionMenuNode && <ScmInlineAction key={index} {...{ node, args, commands, model, treeNode, contextKeys }} />)}
758
+ </div>
759
+ {children}
760
+ </div>;
761
+ }
762
+ }
763
+ export namespace ScmInlineActions {
764
+ export interface Props {
765
+ hover: boolean;
766
+ menu: CompoundMenuNode;
767
+ commands: CommandRegistry;
768
+ model: ScmTreeModel;
769
+ treeNode: TreeNode;
770
+ contextKeys: ScmContextKeyService;
771
+ args: any[];
772
+ children?: React.ReactNode;
773
+ }
774
+ }
775
+
776
+ export class ScmInlineAction extends React.Component<ScmInlineAction.Props> {
777
+ override render(): React.ReactNode {
778
+ const { node, model, treeNode, args, commands, contextKeys } = this.props;
779
+
780
+ let isActive: boolean = false;
781
+ model.execInNodeContext(treeNode, () => {
782
+ isActive = contextKeys.match(node.when);
783
+ });
784
+
785
+ if (!commands.isVisible(node.command, ...args) || !isActive) {
786
+ return false;
787
+ }
788
+ return <div className='theia-scm-inline-action'>
789
+ <a className={`${node.icon} ${ACTION_ITEM}`} title={node.label} onClick={this.execute} />
790
+ </div>;
791
+ }
792
+
793
+ protected execute = (event: React.MouseEvent) => {
794
+ event.stopPropagation();
795
+
796
+ const { commands, node, args } = this.props;
797
+ commands.executeCommand(node.command, ...args);
798
+ };
799
+ }
800
+ export namespace ScmInlineAction {
801
+ export interface Props {
802
+ node: ActionMenuNode;
803
+ commands: CommandRegistry;
804
+ model: ScmTreeModel;
805
+ treeNode: TreeNode;
806
+ contextKeys: ScmContextKeyService;
807
+ args: any[];
808
+ }
809
+ }