@codingame/monaco-vscode-explorer-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/explorer.js +4 -4
- package/package.json +2 -2
- package/external/tslib/tslib.es6.js +0 -11
- package/override/vs/platform/dialogs/common/dialogs.js +0 -10
- package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +0 -432
- package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +0 -788
- package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +0 -512
- package/vscode/src/vs/workbench/contrib/files/browser/files.explorer.contribution.js +0 -461
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import { toErrorMessage } from 'vscode/vscode/vs/base/common/errorMessage';
|
|
2
|
-
import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
3
|
-
import { dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
5
|
-
import { isWeb, isWindows } from 'vscode/vscode/vs/base/common/platform';
|
|
6
|
-
import { basename, joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
7
|
-
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
8
|
-
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
9
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
10
|
-
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
|
|
11
|
-
import { CommandsRegistry, ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
12
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
13
|
-
import { ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
14
|
-
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
15
|
-
import { EditorResolution, EditorOpenSource } from 'vscode/vscode/vs/platform/editor/common/editor';
|
|
16
|
-
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment';
|
|
17
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
18
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
19
|
-
import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
20
|
-
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
21
|
-
import { IListService } from 'vscode/vscode/vs/platform/list/browser/listService';
|
|
22
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
23
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
24
|
-
import { isWorkspaceToOpen } from 'vscode/vscode/vs/platform/window/common/window';
|
|
25
|
-
import { IWorkspaceContextService, UNTITLED_WORKSPACE_NAME } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
26
|
-
import { RemoveRootFolderAction } from 'vscode/vscode/vs/workbench/browser/actions/workspaceActions';
|
|
27
|
-
import { EditorResourceAccessor, SideBySideEditor } from 'vscode/vscode/vs/workbench/common/editor';
|
|
28
|
-
import { IExplorerService, getMultiSelectedResources, getResourceForCommand, getOpenEditorsViewMultiSelection } from 'vscode/vscode/vs/workbench/contrib/files/browser/files';
|
|
29
|
-
import { OpenEditorsView } from 'vscode/vscode/vs/workbench/contrib/files/browser/views/openEditorsView';
|
|
30
|
-
import { ExplorerFocusCondition, FilesExplorerFocusCondition, ExplorerFolderContext, TextFileContentProvider, VIEW_ID, ExplorerCompressedFocusContext, ExplorerCompressedFirstFocusContext, VIEWLET_ID, ExplorerCompressedLastFocusContext } from 'vscode/vscode/vs/workbench/contrib/files/common/files';
|
|
31
|
-
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
32
|
-
import { IEditorService, SIDE_GROUP } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
33
|
-
import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
|
|
34
|
-
import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite';
|
|
35
|
-
import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
|
|
36
|
-
import { IWorkspaceEditingService } from 'vscode/vscode/vs/workbench/services/workspaces/common/workspaceEditing';
|
|
37
|
-
import { OPEN_TO_SIDE_COMMAND_ID, COMPARE_WITH_SAVED_COMMAND_ID, SELECT_FOR_COMPARE_COMMAND_ID, ResourceSelectedForCompareContext, COMPARE_SELECTED_COMMAND_ID, COMPARE_RESOURCE_COMMAND_ID, COPY_PATH_COMMAND_ID, COPY_RELATIVE_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, OPEN_WITH_EXPLORER_COMMAND_ID, REVERT_FILE_COMMAND_ID, REMOVE_ROOT_FOLDER_COMMAND_ID, PREVIOUS_COMPRESSED_FOLDER, NEXT_COMPRESSED_FOLDER, FIRST_COMPRESSED_FOLDER, LAST_COMPRESSED_FOLDER, NEW_UNTITLED_FILE_COMMAND_ID, NEW_UNTITLED_FILE_LABEL, NEW_FILE_COMMAND_ID } from 'vscode/vscode/vs/workbench/contrib/files/browser/fileConstants';
|
|
38
|
-
import 'vscode/vscode/vs/workbench/contrib/files/browser/fileCommands.save';
|
|
39
|
-
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
40
|
-
|
|
41
|
-
const openWindowCommand = (accessor, toOpen, options) => {
|
|
42
|
-
if (Array.isArray(toOpen)) {
|
|
43
|
-
const hostService = accessor.get(IHostService);
|
|
44
|
-
const environmentService = accessor.get(IEnvironmentService);
|
|
45
|
-
toOpen = ( toOpen.map(openable => {
|
|
46
|
-
if (isWorkspaceToOpen(openable) && openable.workspaceUri.scheme === Schemas.untitled) {
|
|
47
|
-
return {
|
|
48
|
-
workspaceUri: joinPath(environmentService.untitledWorkspacesHome, openable.workspaceUri.path, UNTITLED_WORKSPACE_NAME)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return openable;
|
|
52
|
-
}));
|
|
53
|
-
hostService.openWindow(toOpen, options);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const newWindowCommand = (accessor, options) => {
|
|
57
|
-
const hostService = accessor.get(IHostService);
|
|
58
|
-
hostService.openWindow(options);
|
|
59
|
-
};
|
|
60
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
61
|
-
weight: 200 ,
|
|
62
|
-
when: ExplorerFocusCondition,
|
|
63
|
-
primary: 2048 | 3 ,
|
|
64
|
-
mac: {
|
|
65
|
-
primary: 256 | 3
|
|
66
|
-
},
|
|
67
|
-
id: OPEN_TO_SIDE_COMMAND_ID, handler: async (accessor, resource) => {
|
|
68
|
-
const editorService = accessor.get(IEditorService);
|
|
69
|
-
const listService = accessor.get(IListService);
|
|
70
|
-
const fileService = accessor.get(IFileService);
|
|
71
|
-
const explorerService = accessor.get(IExplorerService);
|
|
72
|
-
const resources = getMultiSelectedResources(resource, listService, editorService, explorerService);
|
|
73
|
-
if (resources.length) {
|
|
74
|
-
const untitledResources = resources.filter(resource => resource.scheme === Schemas.untitled);
|
|
75
|
-
const fileResources = resources.filter(resource => resource.scheme !== Schemas.untitled);
|
|
76
|
-
const items = await Promise.all(( fileResources.map(async (resource) => {
|
|
77
|
-
const item = explorerService.findClosest(resource);
|
|
78
|
-
if (item) {
|
|
79
|
-
return item;
|
|
80
|
-
}
|
|
81
|
-
return await fileService.stat(resource);
|
|
82
|
-
})));
|
|
83
|
-
const files = items.filter(i => !i.isDirectory);
|
|
84
|
-
const editors = ( files.map(f => ({
|
|
85
|
-
resource: f.resource,
|
|
86
|
-
options: { pinned: true }
|
|
87
|
-
}))).concat(...( untitledResources.map(
|
|
88
|
-
untitledResource => ({ resource: untitledResource, options: { pinned: true } })
|
|
89
|
-
)));
|
|
90
|
-
await editorService.openEditors(editors, SIDE_GROUP);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
95
|
-
weight: 200 + 10,
|
|
96
|
-
when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerFolderContext.toNegated()))),
|
|
97
|
-
primary: 3 ,
|
|
98
|
-
mac: {
|
|
99
|
-
primary: 2048 | 18
|
|
100
|
-
},
|
|
101
|
-
id: 'explorer.openAndPassFocus', handler: async (accessor, _resource) => {
|
|
102
|
-
const editorService = accessor.get(IEditorService);
|
|
103
|
-
const explorerService = accessor.get(IExplorerService);
|
|
104
|
-
const resources = explorerService.getContext(true);
|
|
105
|
-
if (resources.length) {
|
|
106
|
-
await editorService.openEditors(( resources.map(
|
|
107
|
-
r => ({ resource: r.resource, options: { preserveFocus: false, pinned: true } })
|
|
108
|
-
)));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
const COMPARE_WITH_SAVED_SCHEMA = 'showModifications';
|
|
113
|
-
let providerDisposables = [];
|
|
114
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
115
|
-
id: COMPARE_WITH_SAVED_COMMAND_ID,
|
|
116
|
-
when: undefined,
|
|
117
|
-
weight: 200 ,
|
|
118
|
-
primary: KeyChord(2048 | 41 , 34 ),
|
|
119
|
-
handler: async (accessor, resource) => {
|
|
120
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
121
|
-
const textModelService = accessor.get(ITextModelService);
|
|
122
|
-
const editorService = accessor.get(IEditorService);
|
|
123
|
-
const fileService = accessor.get(IFileService);
|
|
124
|
-
let registerEditorListener = false;
|
|
125
|
-
if (providerDisposables.length === 0) {
|
|
126
|
-
registerEditorListener = true;
|
|
127
|
-
const provider = instantiationService.createInstance(TextFileContentProvider);
|
|
128
|
-
providerDisposables.push(provider);
|
|
129
|
-
providerDisposables.push(textModelService.registerTextModelContentProvider(COMPARE_WITH_SAVED_SCHEMA, provider));
|
|
130
|
-
}
|
|
131
|
-
const uri = getResourceForCommand(resource, accessor.get(IListService), editorService);
|
|
132
|
-
if (uri && fileService.hasProvider(uri)) {
|
|
133
|
-
const name = basename(uri);
|
|
134
|
-
const editorLabel = ( localizeWithPath(
|
|
135
|
-
'vs/workbench/contrib/files/browser/fileCommands',
|
|
136
|
-
'modifiedLabel',
|
|
137
|
-
"{0} (in file) ↔ {1}",
|
|
138
|
-
name,
|
|
139
|
-
name
|
|
140
|
-
));
|
|
141
|
-
try {
|
|
142
|
-
await TextFileContentProvider.open(uri, COMPARE_WITH_SAVED_SCHEMA, editorLabel, editorService, { pinned: true });
|
|
143
|
-
if (registerEditorListener) {
|
|
144
|
-
providerDisposables.push(editorService.onDidVisibleEditorsChange(() => {
|
|
145
|
-
if (!( editorService.editors.some(
|
|
146
|
-
editor => !!EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: COMPARE_WITH_SAVED_SCHEMA })
|
|
147
|
-
))) {
|
|
148
|
-
providerDisposables = dispose(providerDisposables);
|
|
149
|
-
}
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
providerDisposables = dispose(providerDisposables);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
let globalResourceToCompare;
|
|
160
|
-
let resourceSelectedForCompareContext;
|
|
161
|
-
CommandsRegistry.registerCommand({
|
|
162
|
-
id: SELECT_FOR_COMPARE_COMMAND_ID,
|
|
163
|
-
handler: (accessor, resource) => {
|
|
164
|
-
const listService = accessor.get(IListService);
|
|
165
|
-
globalResourceToCompare = getResourceForCommand(resource, listService, accessor.get(IEditorService));
|
|
166
|
-
if (!resourceSelectedForCompareContext) {
|
|
167
|
-
resourceSelectedForCompareContext = ResourceSelectedForCompareContext.bindTo(accessor.get(IContextKeyService));
|
|
168
|
-
}
|
|
169
|
-
resourceSelectedForCompareContext.set(true);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
CommandsRegistry.registerCommand({
|
|
173
|
-
id: COMPARE_SELECTED_COMMAND_ID,
|
|
174
|
-
handler: async (accessor, resource) => {
|
|
175
|
-
const editorService = accessor.get(IEditorService);
|
|
176
|
-
const explorerService = accessor.get(IExplorerService);
|
|
177
|
-
const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService, explorerService);
|
|
178
|
-
if (resources.length === 2) {
|
|
179
|
-
return editorService.openEditor({
|
|
180
|
-
original: { resource: resources[0] },
|
|
181
|
-
modified: { resource: resources[1] },
|
|
182
|
-
options: { pinned: true }
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
CommandsRegistry.registerCommand({
|
|
189
|
-
id: COMPARE_RESOURCE_COMMAND_ID,
|
|
190
|
-
handler: (accessor, resource) => {
|
|
191
|
-
const editorService = accessor.get(IEditorService);
|
|
192
|
-
const listService = accessor.get(IListService);
|
|
193
|
-
const rightResource = getResourceForCommand(resource, listService, editorService);
|
|
194
|
-
if (globalResourceToCompare && rightResource) {
|
|
195
|
-
editorService.openEditor({
|
|
196
|
-
original: { resource: globalResourceToCompare },
|
|
197
|
-
modified: { resource: rightResource },
|
|
198
|
-
options: { pinned: true }
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
async function resourcesToClipboard(resources, relative, clipboardService, labelService, configurationService) {
|
|
204
|
-
if (resources.length) {
|
|
205
|
-
const lineDelimiter = isWindows ? '\r\n' : '\n';
|
|
206
|
-
let separator = undefined;
|
|
207
|
-
if (relative) {
|
|
208
|
-
const relativeSeparator = configurationService.getValue('explorer.copyRelativePathSeparator');
|
|
209
|
-
if (relativeSeparator === '/' || relativeSeparator === '\\') {
|
|
210
|
-
separator = relativeSeparator;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const text = ( resources.map(
|
|
214
|
-
resource => labelService.getUriLabel(resource, { relative, noPrefix: true, separator })
|
|
215
|
-
)).join(lineDelimiter);
|
|
216
|
-
await clipboardService.writeText(text);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const copyPathCommandHandler = async (accessor, resource) => {
|
|
220
|
-
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IExplorerService));
|
|
221
|
-
await resourcesToClipboard(resources, false, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
|
|
222
|
-
};
|
|
223
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
224
|
-
weight: 200 ,
|
|
225
|
-
when: ( EditorContextKeys.focus.toNegated()),
|
|
226
|
-
primary: 2048 | 512 | 33 ,
|
|
227
|
-
win: {
|
|
228
|
-
primary: 1024 | 512 | 33
|
|
229
|
-
},
|
|
230
|
-
id: COPY_PATH_COMMAND_ID,
|
|
231
|
-
handler: copyPathCommandHandler
|
|
232
|
-
});
|
|
233
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
234
|
-
weight: 200 ,
|
|
235
|
-
when: EditorContextKeys.focus,
|
|
236
|
-
primary: KeyChord(2048 | 41 , 2048 | 512 | 33 ),
|
|
237
|
-
win: {
|
|
238
|
-
primary: 1024 | 512 | 33
|
|
239
|
-
},
|
|
240
|
-
id: COPY_PATH_COMMAND_ID,
|
|
241
|
-
handler: copyPathCommandHandler
|
|
242
|
-
});
|
|
243
|
-
const copyRelativePathCommandHandler = async (accessor, resource) => {
|
|
244
|
-
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IExplorerService));
|
|
245
|
-
await resourcesToClipboard(resources, true, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
|
|
246
|
-
};
|
|
247
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
248
|
-
weight: 200 ,
|
|
249
|
-
when: ( EditorContextKeys.focus.toNegated()),
|
|
250
|
-
primary: 2048 | 1024 | 512 | 33 ,
|
|
251
|
-
win: {
|
|
252
|
-
primary: KeyChord(2048 | 41 , 2048 | 1024 | 33 )
|
|
253
|
-
},
|
|
254
|
-
id: COPY_RELATIVE_PATH_COMMAND_ID,
|
|
255
|
-
handler: copyRelativePathCommandHandler
|
|
256
|
-
});
|
|
257
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
258
|
-
weight: 200 ,
|
|
259
|
-
when: EditorContextKeys.focus,
|
|
260
|
-
primary: KeyChord(2048 | 41 , 2048 | 1024 | 512 | 33 ),
|
|
261
|
-
win: {
|
|
262
|
-
primary: KeyChord(2048 | 41 , 2048 | 1024 | 33 )
|
|
263
|
-
},
|
|
264
|
-
id: COPY_RELATIVE_PATH_COMMAND_ID,
|
|
265
|
-
handler: copyRelativePathCommandHandler
|
|
266
|
-
});
|
|
267
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
268
|
-
weight: 200 ,
|
|
269
|
-
when: undefined,
|
|
270
|
-
primary: KeyChord(2048 | 41 , 46 ),
|
|
271
|
-
id: 'workbench.action.files.copyPathOfActiveFile',
|
|
272
|
-
handler: async (accessor) => {
|
|
273
|
-
const editorService = accessor.get(IEditorService);
|
|
274
|
-
const activeInput = editorService.activeEditor;
|
|
275
|
-
const resource = EditorResourceAccessor.getOriginalUri(activeInput, { supportSideBySide: SideBySideEditor.PRIMARY });
|
|
276
|
-
const resources = resource ? [resource] : [];
|
|
277
|
-
await resourcesToClipboard(resources, false, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
CommandsRegistry.registerCommand({
|
|
281
|
-
id: REVEAL_IN_EXPLORER_COMMAND_ID,
|
|
282
|
-
handler: async (accessor, resource) => {
|
|
283
|
-
const viewService = accessor.get(IViewsService);
|
|
284
|
-
const contextService = accessor.get(IWorkspaceContextService);
|
|
285
|
-
const explorerService = accessor.get(IExplorerService);
|
|
286
|
-
const uri = getResourceForCommand(resource, accessor.get(IListService), accessor.get(IEditorService));
|
|
287
|
-
if (uri && contextService.isInsideWorkspace(uri)) {
|
|
288
|
-
const explorerView = await viewService.openView(VIEW_ID, false);
|
|
289
|
-
if (explorerView) {
|
|
290
|
-
const oldAutoReveal = explorerView.autoReveal;
|
|
291
|
-
explorerView.autoReveal = false;
|
|
292
|
-
explorerView.setExpanded(true);
|
|
293
|
-
await explorerService.select(uri, 'force');
|
|
294
|
-
explorerView.focus();
|
|
295
|
-
explorerView.autoReveal = oldAutoReveal;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
const openEditorsView = await viewService.openView(OpenEditorsView.ID, false);
|
|
300
|
-
if (openEditorsView) {
|
|
301
|
-
openEditorsView.setExpanded(true);
|
|
302
|
-
openEditorsView.focus();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
CommandsRegistry.registerCommand({
|
|
308
|
-
id: OPEN_WITH_EXPLORER_COMMAND_ID,
|
|
309
|
-
handler: async (accessor, resource) => {
|
|
310
|
-
const editorService = accessor.get(IEditorService);
|
|
311
|
-
const uri = getResourceForCommand(resource, accessor.get(IListService), accessor.get(IEditorService));
|
|
312
|
-
if (uri) {
|
|
313
|
-
return editorService.openEditor({ resource: uri, options: { override: EditorResolution.PICK, source: EditorOpenSource.USER } });
|
|
314
|
-
}
|
|
315
|
-
return undefined;
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
CommandsRegistry.registerCommand({
|
|
319
|
-
id: REVERT_FILE_COMMAND_ID,
|
|
320
|
-
handler: async (accessor) => {
|
|
321
|
-
const notificationService = accessor.get(INotificationService);
|
|
322
|
-
const listService = accessor.get(IListService);
|
|
323
|
-
const editorGroupService = accessor.get(IEditorGroupsService);
|
|
324
|
-
const editorService = accessor.get(IEditorService);
|
|
325
|
-
let editors = getOpenEditorsViewMultiSelection(listService);
|
|
326
|
-
if (!editors) {
|
|
327
|
-
const activeGroup = editorGroupService.activeGroup;
|
|
328
|
-
if (activeGroup.activeEditor) {
|
|
329
|
-
editors = [{ groupId: activeGroup.id, editor: activeGroup.activeEditor }];
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if (!editors || editors.length === 0) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
try {
|
|
336
|
-
await editorService.revert(editors.filter(({ editor }) => !editor.hasCapability(4 ) ), { force: true });
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
notificationService.error(( localizeWithPath(
|
|
340
|
-
'vs/workbench/contrib/files/browser/fileCommands',
|
|
341
|
-
'genericRevertError',
|
|
342
|
-
"Failed to revert '{0}': {1}",
|
|
343
|
-
( editors.map(({ editor }) => editor.getName())).join(', '),
|
|
344
|
-
toErrorMessage(error, false)
|
|
345
|
-
)));
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
CommandsRegistry.registerCommand({
|
|
350
|
-
id: REMOVE_ROOT_FOLDER_COMMAND_ID,
|
|
351
|
-
handler: (accessor, resource) => {
|
|
352
|
-
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
|
|
353
|
-
const contextService = accessor.get(IWorkspaceContextService);
|
|
354
|
-
const uriIdentityService = accessor.get(IUriIdentityService);
|
|
355
|
-
const workspace = contextService.getWorkspace();
|
|
356
|
-
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IExplorerService)).filter(resource => ( workspace.folders.some(folder => uriIdentityService.extUri.isEqual(folder.uri, resource)))
|
|
357
|
-
);
|
|
358
|
-
if (resources.length === 0) {
|
|
359
|
-
const commandService = accessor.get(ICommandService);
|
|
360
|
-
return commandService.executeCommand(RemoveRootFolderAction.ID);
|
|
361
|
-
}
|
|
362
|
-
return workspaceEditingService.removeFolders(resources);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
366
|
-
weight: 200 + 10,
|
|
367
|
-
when: ( ContextKeyExpr.and(
|
|
368
|
-
FilesExplorerFocusCondition,
|
|
369
|
-
ExplorerCompressedFocusContext,
|
|
370
|
-
( ExplorerCompressedFirstFocusContext.negate())
|
|
371
|
-
)),
|
|
372
|
-
primary: 15 ,
|
|
373
|
-
id: PREVIOUS_COMPRESSED_FOLDER,
|
|
374
|
-
handler: accessor => {
|
|
375
|
-
const paneCompositeService = accessor.get(IPaneCompositePartService);
|
|
376
|
-
const viewlet = paneCompositeService.getActivePaneComposite(0 );
|
|
377
|
-
if (viewlet?.getId() !== VIEWLET_ID) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const explorer = viewlet.getViewPaneContainer();
|
|
381
|
-
const view = explorer.getExplorerView();
|
|
382
|
-
view.previousCompressedStat();
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
386
|
-
weight: 200 + 10,
|
|
387
|
-
when: ( ContextKeyExpr.and(
|
|
388
|
-
FilesExplorerFocusCondition,
|
|
389
|
-
ExplorerCompressedFocusContext,
|
|
390
|
-
( ExplorerCompressedLastFocusContext.negate())
|
|
391
|
-
)),
|
|
392
|
-
primary: 17 ,
|
|
393
|
-
id: NEXT_COMPRESSED_FOLDER,
|
|
394
|
-
handler: accessor => {
|
|
395
|
-
const paneCompositeService = accessor.get(IPaneCompositePartService);
|
|
396
|
-
const viewlet = paneCompositeService.getActivePaneComposite(0 );
|
|
397
|
-
if (viewlet?.getId() !== VIEWLET_ID) {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
const explorer = viewlet.getViewPaneContainer();
|
|
401
|
-
const view = explorer.getExplorerView();
|
|
402
|
-
view.nextCompressedStat();
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
406
|
-
weight: 200 + 10,
|
|
407
|
-
when: ( ContextKeyExpr.and(
|
|
408
|
-
FilesExplorerFocusCondition,
|
|
409
|
-
ExplorerCompressedFocusContext,
|
|
410
|
-
( ExplorerCompressedFirstFocusContext.negate())
|
|
411
|
-
)),
|
|
412
|
-
primary: 14 ,
|
|
413
|
-
id: FIRST_COMPRESSED_FOLDER,
|
|
414
|
-
handler: accessor => {
|
|
415
|
-
const paneCompositeService = accessor.get(IPaneCompositePartService);
|
|
416
|
-
const viewlet = paneCompositeService.getActivePaneComposite(0 );
|
|
417
|
-
if (viewlet?.getId() !== VIEWLET_ID) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
const explorer = viewlet.getViewPaneContainer();
|
|
421
|
-
const view = explorer.getExplorerView();
|
|
422
|
-
view.firstCompressedStat();
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
426
|
-
weight: 200 + 10,
|
|
427
|
-
when: ( ContextKeyExpr.and(
|
|
428
|
-
FilesExplorerFocusCondition,
|
|
429
|
-
ExplorerCompressedFocusContext,
|
|
430
|
-
( ExplorerCompressedLastFocusContext.negate())
|
|
431
|
-
)),
|
|
432
|
-
primary: 13 ,
|
|
433
|
-
id: LAST_COMPRESSED_FOLDER,
|
|
434
|
-
handler: accessor => {
|
|
435
|
-
const paneCompositeService = accessor.get(IPaneCompositePartService);
|
|
436
|
-
const viewlet = paneCompositeService.getActivePaneComposite(0 );
|
|
437
|
-
if (viewlet?.getId() !== VIEWLET_ID) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
const explorer = viewlet.getViewPaneContainer();
|
|
441
|
-
const view = explorer.getExplorerView();
|
|
442
|
-
view.lastCompressedStat();
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|
446
|
-
weight: 200 ,
|
|
447
|
-
when: null,
|
|
448
|
-
primary: isWeb ? ((isWindows ? KeyChord(2048 | 41 , 44 ) : 2048 | 512 | 44) ) : 2048 | 44 ,
|
|
449
|
-
secondary: isWeb ? [2048 | 44 ] : undefined,
|
|
450
|
-
id: NEW_UNTITLED_FILE_COMMAND_ID,
|
|
451
|
-
metadata: {
|
|
452
|
-
description: NEW_UNTITLED_FILE_LABEL,
|
|
453
|
-
args: [
|
|
454
|
-
{
|
|
455
|
-
isOptional: true,
|
|
456
|
-
name: 'New Untitled Text File arguments',
|
|
457
|
-
description: 'The editor view type or language ID if known',
|
|
458
|
-
schema: {
|
|
459
|
-
'type': 'object',
|
|
460
|
-
'properties': {
|
|
461
|
-
'viewType': {
|
|
462
|
-
'type': 'string'
|
|
463
|
-
},
|
|
464
|
-
'languageId': {
|
|
465
|
-
'type': 'string'
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
]
|
|
471
|
-
},
|
|
472
|
-
handler: async (accessor, args) => {
|
|
473
|
-
const editorService = accessor.get(IEditorService);
|
|
474
|
-
await editorService.openEditor({
|
|
475
|
-
resource: undefined,
|
|
476
|
-
options: {
|
|
477
|
-
override: args?.viewType,
|
|
478
|
-
pinned: true
|
|
479
|
-
},
|
|
480
|
-
languageId: args?.languageId,
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
CommandsRegistry.registerCommand({
|
|
485
|
-
id: NEW_FILE_COMMAND_ID,
|
|
486
|
-
handler: async (accessor, args) => {
|
|
487
|
-
const editorService = accessor.get(IEditorService);
|
|
488
|
-
const dialogService = accessor.get(IFileDialogService);
|
|
489
|
-
const fileService = accessor.get(IFileService);
|
|
490
|
-
const createFileLocalized = ( localizeWithPath(
|
|
491
|
-
'vs/workbench/contrib/files/browser/fileCommands',
|
|
492
|
-
'newFileCommand.saveLabel',
|
|
493
|
-
"Create File"
|
|
494
|
-
));
|
|
495
|
-
const defaultFileUri = joinPath(await dialogService.defaultFilePath(), args?.fileName ?? 'Untitled.txt');
|
|
496
|
-
const saveUri = await dialogService.showSaveDialog({ saveLabel: createFileLocalized, title: createFileLocalized, defaultUri: defaultFileUri });
|
|
497
|
-
if (!saveUri) {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
await fileService.createFile(saveUri, undefined, { overwrite: true });
|
|
501
|
-
await editorService.openEditor({
|
|
502
|
-
resource: saveUri,
|
|
503
|
-
options: {
|
|
504
|
-
override: args?.viewType,
|
|
505
|
-
pinned: true
|
|
506
|
-
},
|
|
507
|
-
languageId: args?.languageId,
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
export { newWindowCommand, openWindowCommand };
|