@codingame/monaco-vscode-scm-service-override 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/scm.js +4 -4
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/vscode/src/vs/workbench/contrib/scm/browser/activity.js +0 -308
- package/vscode/src/vs/workbench/contrib/scm/browser/media/scm.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/scm/browser/menus.js +0 -280
- package/vscode/src/vs/workbench/contrib/scm/browser/scm.contribution.js +0 -702
- package/vscode/src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.js +0 -174
- package/vscode/src/vs/workbench/contrib/scm/browser/scmRepositoryRenderer.js +0 -136
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewPane.js +0 -3367
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewPaneContainer.js +0 -54
- package/vscode/src/vs/workbench/contrib/scm/browser/scmViewService.js +0 -305
- package/vscode/src/vs/workbench/contrib/scm/browser/util.js +0 -121
- package/vscode/src/vs/workbench/contrib/scm/common/quickDiffService.js +0 -76
- package/vscode/src/vs/workbench/contrib/scm/common/scmService.js +0 -312
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/scm.css.js';
|
|
3
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
5
|
-
import { VIEWLET_ID, ISCMViewService } from 'vscode/vscode/vs/workbench/contrib/scm/common/scm';
|
|
6
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
8
|
-
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
9
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
10
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
11
|
-
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
12
|
-
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
13
|
-
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
14
|
-
import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
|
|
15
|
-
import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
|
|
16
|
-
|
|
17
|
-
let SCMViewPaneContainer = class SCMViewPaneContainer extends ViewPaneContainer {
|
|
18
|
-
constructor(scmViewService, layoutService, telemetryService, instantiationService, contextMenuService, themeService, storageService, configurationService, extensionService, contextService, viewDescriptorService) {
|
|
19
|
-
super(VIEWLET_ID, { mergeViewWithContainerWhenSingleView: true }, instantiationService, configurationService, layoutService, contextMenuService, telemetryService, extensionService, themeService, storageService, contextService, viewDescriptorService);
|
|
20
|
-
this.scmViewService = scmViewService;
|
|
21
|
-
}
|
|
22
|
-
create(parent) {
|
|
23
|
-
super.create(parent);
|
|
24
|
-
parent.classList.add('scm-viewlet');
|
|
25
|
-
}
|
|
26
|
-
getOptimalWidth() {
|
|
27
|
-
return 400;
|
|
28
|
-
}
|
|
29
|
-
getTitle() {
|
|
30
|
-
return ( localizeWithPath(
|
|
31
|
-
'vs/workbench/contrib/scm/browser/scmViewPaneContainer',
|
|
32
|
-
'source control',
|
|
33
|
-
"Source Control"
|
|
34
|
-
));
|
|
35
|
-
}
|
|
36
|
-
getActionsContext() {
|
|
37
|
-
return this.scmViewService.visibleRepositories.length === 1 ? this.scmViewService.visibleRepositories[0].provider : undefined;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
SCMViewPaneContainer = ( __decorate([
|
|
41
|
-
( __param(0, ISCMViewService)),
|
|
42
|
-
( __param(1, IWorkbenchLayoutService)),
|
|
43
|
-
( __param(2, ITelemetryService)),
|
|
44
|
-
( __param(3, IInstantiationService)),
|
|
45
|
-
( __param(4, IContextMenuService)),
|
|
46
|
-
( __param(5, IThemeService)),
|
|
47
|
-
( __param(6, IStorageService)),
|
|
48
|
-
( __param(7, IConfigurationService)),
|
|
49
|
-
( __param(8, IExtensionService)),
|
|
50
|
-
( __param(9, IWorkspaceContextService)),
|
|
51
|
-
( __param(10, IViewDescriptorService))
|
|
52
|
-
], SCMViewPaneContainer));
|
|
53
|
-
|
|
54
|
-
export { SCMViewPaneContainer };
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
-
import { ISCMService } from 'vscode/vscode/vs/workbench/contrib/scm/common/scm';
|
|
5
|
-
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
6
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
-
import { SCMMenus } from './menus.js';
|
|
8
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
9
|
-
import { debounce } from 'vscode/vscode/vs/base/common/decorators';
|
|
10
|
-
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
11
|
-
import { comparePaths, compareFileNames } from 'vscode/vscode/vs/base/common/comparers';
|
|
12
|
-
import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
13
|
-
import { binarySearch } from 'vscode/vscode/vs/base/common/arrays';
|
|
14
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
15
|
-
import { RawContextKey, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
16
|
-
|
|
17
|
-
function getProviderStorageKey(provider) {
|
|
18
|
-
return `${provider.contextValue}:${provider.label}${provider.rootUri ? `:${( provider.rootUri.toString())}` : ''}`;
|
|
19
|
-
}
|
|
20
|
-
function getRepositoryName(workspaceContextService, repository) {
|
|
21
|
-
if (!repository.provider.rootUri) {
|
|
22
|
-
return repository.provider.label;
|
|
23
|
-
}
|
|
24
|
-
const folder = workspaceContextService.getWorkspaceFolder(repository.provider.rootUri);
|
|
25
|
-
return folder?.uri.toString() === ( repository.provider.rootUri.toString()) ? folder.name : basename(repository.provider.rootUri);
|
|
26
|
-
}
|
|
27
|
-
const RepositoryContextKeys = {
|
|
28
|
-
RepositorySortKey: ( new RawContextKey(
|
|
29
|
-
'scmRepositorySortKey',
|
|
30
|
-
"discoveryTime"
|
|
31
|
-
)),
|
|
32
|
-
};
|
|
33
|
-
let SCMViewService = class SCMViewService {
|
|
34
|
-
get repositories() {
|
|
35
|
-
return ( this._repositories.map(r => r.repository));
|
|
36
|
-
}
|
|
37
|
-
get visibleRepositories() {
|
|
38
|
-
if (this._repositoriesSortKey === "discoveryTime" ) {
|
|
39
|
-
return ( this._repositories.filter(r => r.selectionIndex !== -1)
|
|
40
|
-
.sort((r1, r2) => r1.selectionIndex - r2.selectionIndex)
|
|
41
|
-
.map(r => r.repository));
|
|
42
|
-
}
|
|
43
|
-
return ( this._repositories
|
|
44
|
-
.filter(r => r.selectionIndex !== -1)
|
|
45
|
-
.map(r => r.repository));
|
|
46
|
-
}
|
|
47
|
-
set visibleRepositories(visibleRepositories) {
|
|
48
|
-
const set = ( new Set(visibleRepositories));
|
|
49
|
-
const added = ( new Set());
|
|
50
|
-
const removed = ( new Set());
|
|
51
|
-
for (const repositoryView of this._repositories) {
|
|
52
|
-
if (!( set.has(repositoryView.repository)) && repositoryView.selectionIndex !== -1) {
|
|
53
|
-
repositoryView.selectionIndex = -1;
|
|
54
|
-
removed.add(repositoryView.repository);
|
|
55
|
-
}
|
|
56
|
-
if (( set.has(repositoryView.repository))) {
|
|
57
|
-
if (repositoryView.selectionIndex === -1) {
|
|
58
|
-
added.add(repositoryView.repository);
|
|
59
|
-
}
|
|
60
|
-
repositoryView.selectionIndex = visibleRepositories.indexOf(repositoryView.repository);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (added.size === 0 && removed.size === 0) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
this._onDidSetVisibleRepositories.fire({ added, removed });
|
|
67
|
-
if (this._repositories.find(r => r.focused && r.selectionIndex === -1)) {
|
|
68
|
-
this.focus(this._repositories.find(r => r.selectionIndex !== -1)?.repository);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
get focusedRepository() {
|
|
72
|
-
return this._repositories.find(r => r.focused)?.repository;
|
|
73
|
-
}
|
|
74
|
-
constructor(scmService, contextKeyService, instantiationService, configurationService, storageService, workspaceContextService) {
|
|
75
|
-
this.configurationService = configurationService;
|
|
76
|
-
this.storageService = storageService;
|
|
77
|
-
this.workspaceContextService = workspaceContextService;
|
|
78
|
-
this.didFinishLoading = false;
|
|
79
|
-
this.didSelectRepository = false;
|
|
80
|
-
this.disposables = ( new DisposableStore());
|
|
81
|
-
this._repositories = [];
|
|
82
|
-
this._onDidChangeRepositories = ( new Emitter());
|
|
83
|
-
this.onDidChangeRepositories = this._onDidChangeRepositories.event;
|
|
84
|
-
this._onDidSetVisibleRepositories = ( new Emitter());
|
|
85
|
-
this.onDidChangeVisibleRepositories = Event.any(this._onDidSetVisibleRepositories.event, Event.debounce(this._onDidChangeRepositories.event, (last, e) => {
|
|
86
|
-
if (!last) {
|
|
87
|
-
return e;
|
|
88
|
-
}
|
|
89
|
-
const added = ( new Set(last.added));
|
|
90
|
-
const removed = ( new Set(last.removed));
|
|
91
|
-
for (const repository of e.added) {
|
|
92
|
-
if (( removed.has(repository))) {
|
|
93
|
-
removed.delete(repository);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
added.add(repository);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
for (const repository of e.removed) {
|
|
100
|
-
if (( added.has(repository))) {
|
|
101
|
-
added.delete(repository);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
removed.add(repository);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return { added, removed };
|
|
108
|
-
}, 0, undefined, undefined, undefined, this.disposables));
|
|
109
|
-
this._onDidFocusRepository = ( new Emitter());
|
|
110
|
-
this.onDidFocusRepository = this._onDidFocusRepository.event;
|
|
111
|
-
this.menus = instantiationService.createInstance(SCMMenus);
|
|
112
|
-
try {
|
|
113
|
-
this.previousState = JSON.parse(storageService.get('scm:view:visibleRepositories', 1 , ''));
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
}
|
|
117
|
-
this._repositoriesSortKey = this.previousState?.sortKey ?? this.getViewSortOrder();
|
|
118
|
-
this._sortKeyContextKey = RepositoryContextKeys.RepositorySortKey.bindTo(contextKeyService);
|
|
119
|
-
this._sortKeyContextKey.set(this._repositoriesSortKey);
|
|
120
|
-
scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables);
|
|
121
|
-
scmService.onDidRemoveRepository(this.onDidRemoveRepository, this, this.disposables);
|
|
122
|
-
for (const repository of scmService.repositories) {
|
|
123
|
-
this.onDidAddRepository(repository);
|
|
124
|
-
}
|
|
125
|
-
storageService.onWillSaveState(this.onWillSaveState, this, this.disposables);
|
|
126
|
-
}
|
|
127
|
-
onDidAddRepository(repository) {
|
|
128
|
-
if (!this.didFinishLoading) {
|
|
129
|
-
this.eventuallyFinishLoading();
|
|
130
|
-
}
|
|
131
|
-
const repositoryView = {
|
|
132
|
-
repository, discoveryTime: Date.now(), focused: false, selectionIndex: -1
|
|
133
|
-
};
|
|
134
|
-
let removed = Iterable.empty();
|
|
135
|
-
if (this.previousState) {
|
|
136
|
-
const index = this.previousState.all.indexOf(getProviderStorageKey(repository.provider));
|
|
137
|
-
if (index === -1) {
|
|
138
|
-
const added = [];
|
|
139
|
-
this.insertRepositoryView(this._repositories, repositoryView);
|
|
140
|
-
this._repositories.forEach((repositoryView, index) => {
|
|
141
|
-
if (repositoryView.selectionIndex === -1) {
|
|
142
|
-
added.push(repositoryView.repository);
|
|
143
|
-
}
|
|
144
|
-
repositoryView.selectionIndex = index;
|
|
145
|
-
});
|
|
146
|
-
this._onDidChangeRepositories.fire({ added, removed: Iterable.empty() });
|
|
147
|
-
this.didSelectRepository = false;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (this.previousState.visible.indexOf(index) === -1) {
|
|
151
|
-
if (this.didSelectRepository) {
|
|
152
|
-
this.insertRepositoryView(this._repositories, repositoryView);
|
|
153
|
-
this._onDidChangeRepositories.fire({ added: Iterable.empty(), removed: Iterable.empty() });
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
if (!this.didSelectRepository) {
|
|
159
|
-
removed = [...this.visibleRepositories];
|
|
160
|
-
this._repositories.forEach(r => {
|
|
161
|
-
r.focused = false;
|
|
162
|
-
r.selectionIndex = -1;
|
|
163
|
-
});
|
|
164
|
-
this.didSelectRepository = true;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const maxSelectionIndex = this.getMaxSelectionIndex();
|
|
169
|
-
this.insertRepositoryView(this._repositories, { ...repositoryView, selectionIndex: maxSelectionIndex + 1 });
|
|
170
|
-
this._onDidChangeRepositories.fire({ added: [repositoryView.repository], removed });
|
|
171
|
-
if (!this._repositories.find(r => r.focused)) {
|
|
172
|
-
this.focus(repository);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
onDidRemoveRepository(repository) {
|
|
176
|
-
if (!this.didFinishLoading) {
|
|
177
|
-
this.eventuallyFinishLoading();
|
|
178
|
-
}
|
|
179
|
-
const repositoriesIndex = this._repositories.findIndex(r => r.repository === repository);
|
|
180
|
-
if (repositoriesIndex === -1) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
let added = Iterable.empty();
|
|
184
|
-
const repositoryView = this._repositories.splice(repositoriesIndex, 1);
|
|
185
|
-
if (this._repositories.length > 0 && this.visibleRepositories.length === 0) {
|
|
186
|
-
this._repositories[0].selectionIndex = 0;
|
|
187
|
-
added = [this._repositories[0].repository];
|
|
188
|
-
}
|
|
189
|
-
this._onDidChangeRepositories.fire({ added, removed: ( repositoryView.map(r => r.repository)) });
|
|
190
|
-
if (repositoryView.length === 1 && repositoryView[0].focused && this.visibleRepositories.length > 0) {
|
|
191
|
-
this.focus(this.visibleRepositories[0]);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
isVisible(repository) {
|
|
195
|
-
return this._repositories.find(r => r.repository === repository)?.selectionIndex !== -1;
|
|
196
|
-
}
|
|
197
|
-
toggleVisibility(repository, visible) {
|
|
198
|
-
if (typeof visible === 'undefined') {
|
|
199
|
-
visible = !this.isVisible(repository);
|
|
200
|
-
}
|
|
201
|
-
else if (this.isVisible(repository) === visible) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (visible) {
|
|
205
|
-
this.visibleRepositories = [...this.visibleRepositories, repository];
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
const index = this.visibleRepositories.indexOf(repository);
|
|
209
|
-
if (index > -1) {
|
|
210
|
-
this.visibleRepositories = [
|
|
211
|
-
...this.visibleRepositories.slice(0, index),
|
|
212
|
-
...this.visibleRepositories.slice(index + 1)
|
|
213
|
-
];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
toggleSortKey(sortKey) {
|
|
218
|
-
this._repositoriesSortKey = sortKey;
|
|
219
|
-
this._sortKeyContextKey.set(this._repositoriesSortKey);
|
|
220
|
-
this._repositories.sort(this.compareRepositories.bind(this));
|
|
221
|
-
this._onDidChangeRepositories.fire({ added: Iterable.empty(), removed: Iterable.empty() });
|
|
222
|
-
}
|
|
223
|
-
focus(repository) {
|
|
224
|
-
if (repository && !this.isVisible(repository)) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this._repositories.forEach(r => r.focused = r.repository === repository);
|
|
228
|
-
if (this._repositories.find(r => r.focused)) {
|
|
229
|
-
this._onDidFocusRepository.fire(repository);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
compareRepositories(op1, op2) {
|
|
233
|
-
if (this._repositoriesSortKey === "discoveryTime" ) {
|
|
234
|
-
return op1.discoveryTime - op2.discoveryTime;
|
|
235
|
-
}
|
|
236
|
-
if (this._repositoriesSortKey === 'path' && op1.repository.provider.rootUri && op2.repository.provider.rootUri) {
|
|
237
|
-
return comparePaths(op1.repository.provider.rootUri.fsPath, op2.repository.provider.rootUri.fsPath);
|
|
238
|
-
}
|
|
239
|
-
const name1 = getRepositoryName(this.workspaceContextService, op1.repository);
|
|
240
|
-
const name2 = getRepositoryName(this.workspaceContextService, op2.repository);
|
|
241
|
-
const nameComparison = compareFileNames(name1, name2);
|
|
242
|
-
if (nameComparison === 0 && op1.repository.provider.rootUri && op2.repository.provider.rootUri) {
|
|
243
|
-
return comparePaths(op1.repository.provider.rootUri.fsPath, op2.repository.provider.rootUri.fsPath);
|
|
244
|
-
}
|
|
245
|
-
return nameComparison;
|
|
246
|
-
}
|
|
247
|
-
getMaxSelectionIndex() {
|
|
248
|
-
return this._repositories.length === 0 ? -1 :
|
|
249
|
-
Math.max(...( this._repositories.map(r => r.selectionIndex)));
|
|
250
|
-
}
|
|
251
|
-
getViewSortOrder() {
|
|
252
|
-
const sortOder = this.configurationService.getValue('scm.repositories.sortOrder');
|
|
253
|
-
switch (sortOder) {
|
|
254
|
-
case 'discovery time':
|
|
255
|
-
return "discoveryTime" ;
|
|
256
|
-
case 'name':
|
|
257
|
-
return "name" ;
|
|
258
|
-
case 'path':
|
|
259
|
-
return "path" ;
|
|
260
|
-
default:
|
|
261
|
-
return "discoveryTime" ;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
insertRepositoryView(repositories, repositoryView) {
|
|
265
|
-
const index = binarySearch(repositories, repositoryView, this.compareRepositories.bind(this));
|
|
266
|
-
repositories.splice(index < 0 ? ~index : index, 0, repositoryView);
|
|
267
|
-
}
|
|
268
|
-
onWillSaveState() {
|
|
269
|
-
if (!this.didFinishLoading) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const all = ( this.repositories.map(r => getProviderStorageKey(r.provider)));
|
|
273
|
-
const visible = ( this.visibleRepositories.map(r => all.indexOf(getProviderStorageKey(r.provider))));
|
|
274
|
-
const raw = JSON.stringify({ all, sortKey: this._repositoriesSortKey, visible });
|
|
275
|
-
this.storageService.store('scm:view:visibleRepositories', raw, 1 , 1 );
|
|
276
|
-
}
|
|
277
|
-
eventuallyFinishLoading() {
|
|
278
|
-
this.finishLoading();
|
|
279
|
-
}
|
|
280
|
-
finishLoading() {
|
|
281
|
-
if (this.didFinishLoading) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
this.didFinishLoading = true;
|
|
285
|
-
this.previousState = undefined;
|
|
286
|
-
}
|
|
287
|
-
dispose() {
|
|
288
|
-
this.disposables.dispose();
|
|
289
|
-
this._onDidChangeRepositories.dispose();
|
|
290
|
-
this._onDidSetVisibleRepositories.dispose();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
SCMViewService.__decorator = ( __decorate([
|
|
294
|
-
debounce(5000)
|
|
295
|
-
], SCMViewService.prototype, "eventuallyFinishLoading", null));
|
|
296
|
-
SCMViewService = ( __decorate([
|
|
297
|
-
( __param(0, ISCMService)),
|
|
298
|
-
( __param(1, IContextKeyService)),
|
|
299
|
-
( __param(2, IInstantiationService)),
|
|
300
|
-
( __param(3, IConfigurationService)),
|
|
301
|
-
( __param(4, IStorageService)),
|
|
302
|
-
( __param(5, IWorkspaceContextService))
|
|
303
|
-
], SCMViewService));
|
|
304
|
-
|
|
305
|
-
export { RepositoryContextKeys, SCMViewService };
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { basename } from 'vscode/vscode/vs/base/common/path';
|
|
2
|
-
import { MenuItemAction } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
3
|
-
import { Action } from 'vscode/vscode/vs/base/common/actions';
|
|
4
|
-
import { createAndFillInActionBarActions, createAndFillInContextMenuActions, createActionViewItem } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
5
|
-
import { equals } from 'vscode/vscode/vs/base/common/arrays';
|
|
6
|
-
import { ActionViewItem } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionViewItems';
|
|
7
|
-
import { renderLabelWithIcons } from 'vscode/vscode/vs/base/browser/ui/iconLabel/iconLabels';
|
|
8
|
-
import { reset } from 'vscode/vscode/vs/base/browser/dom';
|
|
9
|
-
import { ResourceTree } from 'vscode/vscode/vs/base/common/resourceTree';
|
|
10
|
-
|
|
11
|
-
function isSCMViewService(element) {
|
|
12
|
-
return Array.isArray(element.repositories) && Array.isArray(element.visibleRepositories);
|
|
13
|
-
}
|
|
14
|
-
function isSCMRepository(element) {
|
|
15
|
-
return !!element.provider && !!element.input;
|
|
16
|
-
}
|
|
17
|
-
function isSCMInput(element) {
|
|
18
|
-
return !!element.validateInput && typeof element.value === 'string';
|
|
19
|
-
}
|
|
20
|
-
function isSCMActionButton(element) {
|
|
21
|
-
return element.type === 'actionButton';
|
|
22
|
-
}
|
|
23
|
-
function isSCMResourceGroup(element) {
|
|
24
|
-
return !!element.provider && !!element.resources;
|
|
25
|
-
}
|
|
26
|
-
function isSCMResource(element) {
|
|
27
|
-
return !!element.sourceUri && isSCMResourceGroup(element.resourceGroup);
|
|
28
|
-
}
|
|
29
|
-
function isSCMResourceNode(element) {
|
|
30
|
-
return ResourceTree.isResourceNode(element) && isSCMResourceGroup(element.context);
|
|
31
|
-
}
|
|
32
|
-
function isSCMHistoryItemGroupTreeElement(element) {
|
|
33
|
-
return element.type === 'historyItemGroup';
|
|
34
|
-
}
|
|
35
|
-
function isSCMHistoryItemTreeElement(element) {
|
|
36
|
-
return element.type === 'allChanges' ||
|
|
37
|
-
element.type === 'historyItem';
|
|
38
|
-
}
|
|
39
|
-
function isSCMHistoryItemChangeTreeElement(element) {
|
|
40
|
-
return element.type === 'historyItemChange';
|
|
41
|
-
}
|
|
42
|
-
function isSCMHistoryItemChangeNode(element) {
|
|
43
|
-
return ResourceTree.isResourceNode(element) && isSCMHistoryItemTreeElement(element.context);
|
|
44
|
-
}
|
|
45
|
-
function isSCMViewSeparator(element) {
|
|
46
|
-
return element.type === 'separator';
|
|
47
|
-
}
|
|
48
|
-
function toDiffEditorArguments(uri, originalUri, modifiedUri) {
|
|
49
|
-
const basename$1 = basename(uri.fsPath);
|
|
50
|
-
const originalQuery = JSON.parse(originalUri.query);
|
|
51
|
-
const modifiedQuery = JSON.parse(modifiedUri.query);
|
|
52
|
-
const originalShortRef = originalQuery.ref.substring(0, 8).concat(originalQuery.ref.endsWith('^') ? '^' : '');
|
|
53
|
-
const modifiedShortRef = modifiedQuery.ref.substring(0, 8).concat(modifiedQuery.ref.endsWith('^') ? '^' : '');
|
|
54
|
-
return [originalUri, modifiedUri, `${basename$1} (${originalShortRef}) ↔ ${basename$1} (${modifiedShortRef})`, null];
|
|
55
|
-
}
|
|
56
|
-
const compareActions = (a, b) => {
|
|
57
|
-
if (a instanceof MenuItemAction && b instanceof MenuItemAction) {
|
|
58
|
-
return a.id === b.id && a.enabled === b.enabled && a.hideActions?.isHidden === b.hideActions?.isHidden;
|
|
59
|
-
}
|
|
60
|
-
return a.id === b.id && a.enabled === b.enabled;
|
|
61
|
-
};
|
|
62
|
-
function connectPrimaryMenu(menu, callback, primaryGroup) {
|
|
63
|
-
let cachedPrimary = [];
|
|
64
|
-
let cachedSecondary = [];
|
|
65
|
-
const updateActions = () => {
|
|
66
|
-
const primary = [];
|
|
67
|
-
const secondary = [];
|
|
68
|
-
createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, { primary, secondary }, primaryGroup);
|
|
69
|
-
if (equals(cachedPrimary, primary, compareActions) && equals(cachedSecondary, secondary, compareActions)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
cachedPrimary = primary;
|
|
73
|
-
cachedSecondary = secondary;
|
|
74
|
-
callback(primary, secondary);
|
|
75
|
-
};
|
|
76
|
-
updateActions();
|
|
77
|
-
return menu.onDidChange(updateActions);
|
|
78
|
-
}
|
|
79
|
-
function connectPrimaryMenuToInlineActionBar(menu, actionBar) {
|
|
80
|
-
return connectPrimaryMenu(menu, (primary) => {
|
|
81
|
-
actionBar.clear();
|
|
82
|
-
actionBar.push(primary, { icon: true, label: false });
|
|
83
|
-
}, 'inline');
|
|
84
|
-
}
|
|
85
|
-
function collectContextMenuActions(menu) {
|
|
86
|
-
const primary = [];
|
|
87
|
-
const actions = [];
|
|
88
|
-
createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, { primary, secondary: actions }, 'inline');
|
|
89
|
-
return actions;
|
|
90
|
-
}
|
|
91
|
-
class StatusBarAction extends Action {
|
|
92
|
-
constructor(command, commandService) {
|
|
93
|
-
super(`statusbaraction{${command.id}}`, command.title, '', true);
|
|
94
|
-
this.command = command;
|
|
95
|
-
this.commandService = commandService;
|
|
96
|
-
this.tooltip = command.tooltip || '';
|
|
97
|
-
}
|
|
98
|
-
run() {
|
|
99
|
-
return this.commandService.executeCommand(this.command.id, ...(this.command.arguments || []));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
class StatusBarActionViewItem extends ActionViewItem {
|
|
103
|
-
constructor(action, options) {
|
|
104
|
-
super(null, action, { ...options, icon: false, label: true });
|
|
105
|
-
}
|
|
106
|
-
updateLabel() {
|
|
107
|
-
if (this.options.label && this.label) {
|
|
108
|
-
reset(this.label, ...renderLabelWithIcons(this.action.label));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function getActionViewItemProvider(instaService) {
|
|
113
|
-
return (action, options) => {
|
|
114
|
-
if (action instanceof StatusBarAction) {
|
|
115
|
-
return ( new StatusBarActionViewItem(action, options));
|
|
116
|
-
}
|
|
117
|
-
return createActionViewItem(instaService, action, options);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { StatusBarAction, collectContextMenuActions, connectPrimaryMenu, connectPrimaryMenuToInlineActionBar, getActionViewItemProvider, isSCMActionButton, isSCMHistoryItemChangeNode, isSCMHistoryItemChangeTreeElement, isSCMHistoryItemGroupTreeElement, isSCMHistoryItemTreeElement, isSCMInput, isSCMRepository, isSCMResource, isSCMResourceGroup, isSCMResourceNode, isSCMViewSeparator, isSCMViewService, toDiffEditorArguments };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { isEqualOrParent } from 'vscode/vscode/vs/base/common/resources';
|
|
4
|
-
import { score } from 'vscode/vscode/vs/editor/common/languageSelector';
|
|
5
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
6
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
7
|
-
|
|
8
|
-
function createProviderComparer(uri) {
|
|
9
|
-
return (a, b) => {
|
|
10
|
-
if (a.rootUri && !b.rootUri) {
|
|
11
|
-
return -1;
|
|
12
|
-
}
|
|
13
|
-
else if (!a.rootUri && b.rootUri) {
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
else if (!a.rootUri && !b.rootUri) {
|
|
17
|
-
return 0;
|
|
18
|
-
}
|
|
19
|
-
const aIsParent = isEqualOrParent(uri, a.rootUri);
|
|
20
|
-
const bIsParent = isEqualOrParent(uri, b.rootUri);
|
|
21
|
-
if (aIsParent && bIsParent) {
|
|
22
|
-
return a.rootUri.fsPath.length - b.rootUri.fsPath.length;
|
|
23
|
-
}
|
|
24
|
-
else if (aIsParent) {
|
|
25
|
-
return -1;
|
|
26
|
-
}
|
|
27
|
-
else if (bIsParent) {
|
|
28
|
-
return 1;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
let QuickDiffService = class QuickDiffService extends Disposable {
|
|
36
|
-
constructor(uriIdentityService) {
|
|
37
|
-
super();
|
|
38
|
-
this.uriIdentityService = uriIdentityService;
|
|
39
|
-
this.quickDiffProviders = ( new Set());
|
|
40
|
-
this._onDidChangeQuickDiffProviders = this._register(( new Emitter()));
|
|
41
|
-
this.onDidChangeQuickDiffProviders = this._onDidChangeQuickDiffProviders.event;
|
|
42
|
-
}
|
|
43
|
-
addQuickDiffProvider(quickDiff) {
|
|
44
|
-
this.quickDiffProviders.add(quickDiff);
|
|
45
|
-
this._onDidChangeQuickDiffProviders.fire();
|
|
46
|
-
return {
|
|
47
|
-
dispose: () => {
|
|
48
|
-
this.quickDiffProviders.delete(quickDiff);
|
|
49
|
-
this._onDidChangeQuickDiffProviders.fire();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
isQuickDiff(diff) {
|
|
54
|
-
return !!diff.originalResource && (typeof diff.label === 'string') && (typeof diff.isSCM === 'boolean');
|
|
55
|
-
}
|
|
56
|
-
async getQuickDiffs(uri, language = '', isSynchronized = false) {
|
|
57
|
-
const providers = Array.from(this.quickDiffProviders)
|
|
58
|
-
.filter(provider => !provider.rootUri || this.uriIdentityService.extUri.isEqualOrParent(uri, provider.rootUri))
|
|
59
|
-
.sort(createProviderComparer(uri));
|
|
60
|
-
const diffs = await Promise.all(( providers.map(async (provider) => {
|
|
61
|
-
const scoreValue = provider.selector ? score(provider.selector, uri, language, isSynchronized, undefined, undefined) : 10;
|
|
62
|
-
const diff = {
|
|
63
|
-
originalResource: scoreValue > 0 ? (await provider.getOriginalResource(uri)) ?? undefined : undefined,
|
|
64
|
-
label: provider.label,
|
|
65
|
-
isSCM: provider.isSCM
|
|
66
|
-
};
|
|
67
|
-
return diff;
|
|
68
|
-
})));
|
|
69
|
-
return diffs.filter(this.isQuickDiff);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
QuickDiffService = ( __decorate([
|
|
73
|
-
( __param(0, IUriIdentityService))
|
|
74
|
-
], QuickDiffService));
|
|
75
|
-
|
|
76
|
-
export { QuickDiffService };
|