@codingame/monaco-vscode-explorer-service-override 3.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.
@@ -0,0 +1,788 @@
1
+ import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
2
+ import { GlobalCompareResourcesAction, FocusFilesExplorer, ShowActiveFileInExplorer, CompareWithClipboardAction, CompareNewUntitledTextFilesAction, ToggleAutoSaveAction, OpenActiveFileInEmptyWorkspace, SetActiveEditorReadonlyInSession, SetActiveEditorWriteableInSession, ToggleActiveEditorReadonlyInSession, ResetActiveEditorReadonlyInSession, renameHandler, moveFileToTrashHandler, deleteFileHandler, cutFileHandler, copyFileHandler, pasteFileHandler, openFilePreserveFocusHandler, NEW_FILE_COMMAND_ID, NEW_FILE_LABEL, NEW_FOLDER_COMMAND_ID, NEW_FOLDER_LABEL, COPY_FILE_LABEL, PASTE_FILE_LABEL, FileCopiedContext, DOWNLOAD_COMMAND_ID, DOWNLOAD_LABEL, UPLOAD_COMMAND_ID, UPLOAD_LABEL, TRIGGER_RENAME_LABEL, MOVE_FILE_TO_TRASH_LABEL } from 'vscode/vscode/vs/workbench/contrib/files/browser/fileActions';
3
+ import { CONFLICT_RESOLUTION_CONTEXT, acceptLocalChangesCommand, revertLocalChangesCommand } from 'vscode/vscode/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler';
4
+ import { registerAction2, MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
5
+ import { openWindowCommand, newWindowCommand } from './fileCommands.js';
6
+ import { COPY_PATH_COMMAND_ID, COPY_RELATIVE_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, SAVE_FILE_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID, SAVE_FILE_WITHOUT_FORMATTING_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID, SAVE_FILES_COMMAND_ID, REVERT_FILE_COMMAND_ID, COMPARE_WITH_SAVED_COMMAND_ID, SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, NEW_UNTITLED_FILE_COMMAND_ID, NEW_UNTITLED_FILE_LABEL, OPEN_TO_SIDE_COMMAND_ID, OpenEditorsDirtyEditorContext, OpenEditorsGroupContext, OpenEditorsReadonlyEditorContext, COMPARE_RESOURCE_COMMAND_ID, ResourceSelectedForCompareContext, SELECT_FOR_COMPARE_COMMAND_ID, COMPARE_SELECTED_COMMAND_ID, OPEN_WITH_EXPLORER_COMMAND_ID, REMOVE_ROOT_FOLDER_COMMAND_ID, REMOVE_ROOT_FOLDER_LABEL, SAVE_ALL_COMMAND_ID } from 'vscode/vscode/vs/workbench/contrib/files/browser/fileConstants';
7
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
8
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
+ import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
10
+ import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerResourceNotReadonlyContext, ExplorerResourceMoveableToTrash, ExplorerResourceCut, ExplorerFolderContext, ExplorerResourceAvailableEditorIdsContext, FoldersViewVisibleContext } from 'vscode/vscode/vs/workbench/contrib/files/common/files';
11
+ import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL } from 'vscode/vscode/vs/workbench/browser/actions/workspaceCommands';
12
+ import { REOPEN_WITH_COMMAND_ID, CLOSE_EDITOR_COMMAND_ID, CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, CLOSE_SAVED_EDITORS_COMMAND_ID, CLOSE_EDITORS_IN_GROUP_COMMAND_ID } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorCommands';
13
+ import { AutoSaveAfterShortDelayContext } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
14
+ import { WorkbenchListDoubleSelection } from 'vscode/vscode/vs/platform/list/browser/listService';
15
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
16
+ import { ResourceContextKey, WorkspaceFolderCountContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, HasWebFileSystemAccess, EnterMultiRootWorkspaceSupportContext, WorkbenchStateContext, ActiveEditorContext, SidebarFocusContext, ActiveEditorCanRevertContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
17
+ import { IsWebContext } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
18
+ import { IExplorerService } from 'vscode/vscode/vs/workbench/contrib/files/browser/files';
19
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
20
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
21
+
22
+ registerAction2(GlobalCompareResourcesAction);
23
+ registerAction2(FocusFilesExplorer);
24
+ registerAction2(ShowActiveFileInExplorer);
25
+ registerAction2(CompareWithClipboardAction);
26
+ registerAction2(CompareNewUntitledTextFilesAction);
27
+ registerAction2(ToggleAutoSaveAction);
28
+ registerAction2(OpenActiveFileInEmptyWorkspace);
29
+ registerAction2(SetActiveEditorReadonlyInSession);
30
+ registerAction2(SetActiveEditorWriteableInSession);
31
+ registerAction2(ToggleActiveEditorReadonlyInSession);
32
+ registerAction2(ResetActiveEditorReadonlyInSession);
33
+ CommandsRegistry.registerCommand('_files.windowOpen', openWindowCommand);
34
+ CommandsRegistry.registerCommand('_files.newWindow', newWindowCommand);
35
+ const explorerCommandsWeightBonus = 10;
36
+ const RENAME_ID = 'renameFile';
37
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
38
+ id: RENAME_ID,
39
+ weight: 200 + explorerCommandsWeightBonus,
40
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()), ExplorerResourceNotReadonlyContext)),
41
+ primary: 60 ,
42
+ mac: {
43
+ primary: 3
44
+ },
45
+ handler: renameHandler
46
+ });
47
+ const MOVE_FILE_TO_TRASH_ID = 'moveFileToTrash';
48
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
49
+ id: MOVE_FILE_TO_TRASH_ID,
50
+ weight: 200 + explorerCommandsWeightBonus,
51
+ when: ( ContextKeyExpr.and(
52
+ FilesExplorerFocusCondition,
53
+ ExplorerResourceNotReadonlyContext,
54
+ ExplorerResourceMoveableToTrash
55
+ )),
56
+ primary: 20 ,
57
+ mac: {
58
+ primary: 2048 | 1 ,
59
+ secondary: [20 ]
60
+ },
61
+ handler: moveFileToTrashHandler
62
+ });
63
+ const DELETE_FILE_ID = 'deleteFile';
64
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
65
+ id: DELETE_FILE_ID,
66
+ weight: 200 + explorerCommandsWeightBonus,
67
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext)),
68
+ primary: 1024 | 20 ,
69
+ mac: {
70
+ primary: 2048 | 512 | 1
71
+ },
72
+ handler: deleteFileHandler
73
+ });
74
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
75
+ id: DELETE_FILE_ID,
76
+ weight: 200 + explorerCommandsWeightBonus,
77
+ when: ( ContextKeyExpr.and(
78
+ FilesExplorerFocusCondition,
79
+ ExplorerResourceNotReadonlyContext,
80
+ ( ExplorerResourceMoveableToTrash.toNegated())
81
+ )),
82
+ primary: 20 ,
83
+ mac: {
84
+ primary: 2048 | 1
85
+ },
86
+ handler: deleteFileHandler
87
+ });
88
+ const CUT_FILE_ID = 'filesExplorer.cut';
89
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
90
+ id: CUT_FILE_ID,
91
+ weight: 200 + explorerCommandsWeightBonus,
92
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()), ExplorerResourceNotReadonlyContext)),
93
+ primary: 2048 | 54 ,
94
+ handler: cutFileHandler,
95
+ });
96
+ const COPY_FILE_ID = 'filesExplorer.copy';
97
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
98
+ id: COPY_FILE_ID,
99
+ weight: 200 + explorerCommandsWeightBonus,
100
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerRootContext.toNegated()))),
101
+ primary: 2048 | 33 ,
102
+ handler: copyFileHandler,
103
+ });
104
+ const PASTE_FILE_ID = 'filesExplorer.paste';
105
+ CommandsRegistry.registerCommand(PASTE_FILE_ID, pasteFileHandler);
106
+ KeybindingsRegistry.registerKeybindingRule({
107
+ id: `^${PASTE_FILE_ID}`,
108
+ weight: 200 + explorerCommandsWeightBonus,
109
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext)),
110
+ primary: 2048 | 52 ,
111
+ });
112
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
113
+ id: 'filesExplorer.cancelCut',
114
+ weight: 200 + explorerCommandsWeightBonus,
115
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceCut)),
116
+ primary: 9 ,
117
+ handler: async (accessor) => {
118
+ const explorerService = accessor.get(IExplorerService);
119
+ await explorerService.setToCopy([], true);
120
+ }
121
+ });
122
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
123
+ id: 'filesExplorer.openFilePreserveFocus',
124
+ weight: 200 + explorerCommandsWeightBonus,
125
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerFolderContext.toNegated()))),
126
+ primary: 10 ,
127
+ handler: openFilePreserveFocusHandler
128
+ });
129
+ const copyPathCommand = {
130
+ id: COPY_PATH_COMMAND_ID,
131
+ title: ( localizeWithPath(
132
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
133
+ 'copyPath',
134
+ "Copy Path"
135
+ ))
136
+ };
137
+ const copyRelativePathCommand = {
138
+ id: COPY_RELATIVE_PATH_COMMAND_ID,
139
+ title: ( localizeWithPath(
140
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
141
+ 'copyRelativePath',
142
+ "Copy Relative Path"
143
+ ))
144
+ };
145
+ appendEditorTitleContextMenuItem(COPY_PATH_COMMAND_ID, copyPathCommand.title, ResourceContextKey.IsFileSystemResource, '1_cutcopypaste');
146
+ appendEditorTitleContextMenuItem(COPY_RELATIVE_PATH_COMMAND_ID, copyRelativePathCommand.title, ResourceContextKey.IsFileSystemResource, '1_cutcopypaste');
147
+ appendEditorTitleContextMenuItem(REVEAL_IN_EXPLORER_COMMAND_ID, ( localizeWithPath(
148
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
149
+ 'revealInSideBar',
150
+ "Reveal in Explorer View"
151
+ )), ResourceContextKey.IsFileSystemResource, '2_files', 1);
152
+ function appendEditorTitleContextMenuItem(id, title, when, group, order) {
153
+ MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, {
154
+ command: { id, title },
155
+ when,
156
+ group,
157
+ order
158
+ });
159
+ }
160
+ appendSaveConflictEditorTitleAction('workbench.files.action.acceptLocalChanges', ( localizeWithPath(
161
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
162
+ 'acceptLocalChanges',
163
+ "Use your changes and overwrite file contents"
164
+ )), Codicon.check, -10, acceptLocalChangesCommand);
165
+ appendSaveConflictEditorTitleAction('workbench.files.action.revertLocalChanges', ( localizeWithPath(
166
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
167
+ 'revertLocalChanges',
168
+ "Discard your changes and revert to file contents"
169
+ )), Codicon.discard, -9, revertLocalChangesCommand);
170
+ function appendSaveConflictEditorTitleAction(id, title, icon, order, command) {
171
+ CommandsRegistry.registerCommand(id, command);
172
+ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
173
+ command: { id, title, icon },
174
+ when: ( ContextKeyExpr.equals(CONFLICT_RESOLUTION_CONTEXT, true)),
175
+ group: 'navigation',
176
+ order
177
+ });
178
+ }
179
+ function appendToCommandPalette({ id, title, category, metadata }, when) {
180
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
181
+ command: {
182
+ id,
183
+ title,
184
+ category,
185
+ metadata
186
+ },
187
+ when
188
+ });
189
+ }
190
+ appendToCommandPalette({
191
+ id: COPY_PATH_COMMAND_ID,
192
+ title: ( localize2WithPath(
193
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
194
+ 'copyPathOfActive',
195
+ "Copy Path of Active File"
196
+ )),
197
+ category: Categories.File
198
+ });
199
+ appendToCommandPalette({
200
+ id: COPY_RELATIVE_PATH_COMMAND_ID,
201
+ title: ( localize2WithPath(
202
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
203
+ 'copyRelativePathOfActive',
204
+ "Copy Relative Path of Active File"
205
+ )),
206
+ category: Categories.File
207
+ });
208
+ appendToCommandPalette({
209
+ id: SAVE_FILE_COMMAND_ID,
210
+ title: SAVE_FILE_LABEL,
211
+ category: Categories.File
212
+ });
213
+ appendToCommandPalette({
214
+ id: SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID,
215
+ title: SAVE_FILE_WITHOUT_FORMATTING_LABEL,
216
+ category: Categories.File
217
+ });
218
+ appendToCommandPalette({
219
+ id: SAVE_ALL_IN_GROUP_COMMAND_ID,
220
+ title: ( localize2WithPath(
221
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
222
+ 'saveAllInGroup',
223
+ "Save All in Group"
224
+ )),
225
+ category: Categories.File
226
+ });
227
+ appendToCommandPalette({
228
+ id: SAVE_FILES_COMMAND_ID,
229
+ title: ( localize2WithPath(
230
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
231
+ 'saveFiles',
232
+ "Save All Files"
233
+ )),
234
+ category: Categories.File
235
+ });
236
+ appendToCommandPalette({
237
+ id: REVERT_FILE_COMMAND_ID,
238
+ title: ( localize2WithPath(
239
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
240
+ 'revert',
241
+ "Revert File"
242
+ )),
243
+ category: Categories.File
244
+ });
245
+ appendToCommandPalette({
246
+ id: COMPARE_WITH_SAVED_COMMAND_ID,
247
+ title: ( localize2WithPath(
248
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
249
+ 'compareActiveWithSaved',
250
+ "Compare Active File with Saved"
251
+ )),
252
+ category: Categories.File
253
+ });
254
+ appendToCommandPalette({
255
+ id: SAVE_FILE_AS_COMMAND_ID,
256
+ title: SAVE_FILE_AS_LABEL,
257
+ category: Categories.File
258
+ });
259
+ appendToCommandPalette({
260
+ id: NEW_FILE_COMMAND_ID,
261
+ title: NEW_FILE_LABEL,
262
+ category: Categories.File
263
+ }, ( WorkspaceFolderCountContext.notEqualsTo('0')));
264
+ appendToCommandPalette({
265
+ id: NEW_FOLDER_COMMAND_ID,
266
+ title: NEW_FOLDER_LABEL,
267
+ category: Categories.File,
268
+ metadata: { description: ( localize2WithPath(
269
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
270
+ 'newFolderDescription',
271
+ "Create a new folder or directory"
272
+ )) }
273
+ }, ( WorkspaceFolderCountContext.notEqualsTo('0')));
274
+ appendToCommandPalette({
275
+ id: NEW_UNTITLED_FILE_COMMAND_ID,
276
+ title: NEW_UNTITLED_FILE_LABEL,
277
+ category: Categories.File
278
+ });
279
+ const isFileOrUntitledResourceContextKey = ( ContextKeyExpr.or(ResourceContextKey.IsFileSystemResource, ( ResourceContextKey.Scheme.isEqualTo(Schemas.untitled))));
280
+ const openToSideCommand = {
281
+ id: OPEN_TO_SIDE_COMMAND_ID,
282
+ title: ( localizeWithPath(
283
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
284
+ 'openToSide',
285
+ "Open to the Side"
286
+ ))
287
+ };
288
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
289
+ group: 'navigation',
290
+ order: 10,
291
+ command: openToSideCommand,
292
+ when: isFileOrUntitledResourceContextKey
293
+ });
294
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
295
+ group: '1_open',
296
+ order: 10,
297
+ command: {
298
+ id: REOPEN_WITH_COMMAND_ID,
299
+ title: ( localizeWithPath(
300
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
301
+ 'reopenWith',
302
+ "Reopen Editor With..."
303
+ ))
304
+ },
305
+ when: ActiveEditorAvailableEditorIdsContext
306
+ });
307
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
308
+ group: '1_cutcopypaste',
309
+ order: 10,
310
+ command: copyPathCommand,
311
+ when: ResourceContextKey.IsFileSystemResource
312
+ });
313
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
314
+ group: '1_cutcopypaste',
315
+ order: 20,
316
+ command: copyRelativePathCommand,
317
+ when: ResourceContextKey.IsFileSystemResource
318
+ });
319
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
320
+ group: '2_save',
321
+ order: 10,
322
+ command: {
323
+ id: SAVE_FILE_COMMAND_ID,
324
+ title: SAVE_FILE_LABEL,
325
+ precondition: OpenEditorsDirtyEditorContext
326
+ },
327
+ when: ( ContextKeyExpr.or((
328
+ ResourceContextKey.Scheme.isEqualTo(Schemas.untitled)), (
329
+ ContextKeyExpr.and((
330
+ OpenEditorsGroupContext.toNegated()), (
331
+ OpenEditorsReadonlyEditorContext.toNegated()), (
332
+ AutoSaveAfterShortDelayContext.toNegated())))))
333
+ });
334
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
335
+ group: '2_save',
336
+ order: 20,
337
+ command: {
338
+ id: REVERT_FILE_COMMAND_ID,
339
+ title: ( localizeWithPath(
340
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
341
+ 'revert',
342
+ "Revert File"
343
+ )),
344
+ precondition: OpenEditorsDirtyEditorContext
345
+ },
346
+ when: ( ContextKeyExpr.and((
347
+ OpenEditorsGroupContext.toNegated()), (
348
+ OpenEditorsReadonlyEditorContext.toNegated()), (
349
+ ResourceContextKey.Scheme.notEqualsTo(Schemas.untitled)), (
350
+ AutoSaveAfterShortDelayContext.toNegated())))
351
+ });
352
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
353
+ group: '2_save',
354
+ order: 30,
355
+ command: {
356
+ id: SAVE_ALL_IN_GROUP_COMMAND_ID,
357
+ title: ( localizeWithPath(
358
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
359
+ 'saveAll',
360
+ "Save All"
361
+ )),
362
+ precondition: DirtyWorkingCopiesContext
363
+ },
364
+ when: OpenEditorsGroupContext
365
+ });
366
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
367
+ group: '3_compare',
368
+ order: 10,
369
+ command: {
370
+ id: COMPARE_WITH_SAVED_COMMAND_ID,
371
+ title: ( localizeWithPath(
372
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
373
+ 'compareWithSaved',
374
+ "Compare with Saved"
375
+ )),
376
+ precondition: OpenEditorsDirtyEditorContext
377
+ },
378
+ when: ( ContextKeyExpr.and(ResourceContextKey.IsFileSystemResource, ( AutoSaveAfterShortDelayContext.toNegated()), ( WorkbenchListDoubleSelection.toNegated())))
379
+ });
380
+ const compareResourceCommand = {
381
+ id: COMPARE_RESOURCE_COMMAND_ID,
382
+ title: ( localizeWithPath(
383
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
384
+ 'compareWithSelected',
385
+ "Compare with Selected"
386
+ ))
387
+ };
388
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
389
+ group: '3_compare',
390
+ order: 20,
391
+ command: compareResourceCommand,
392
+ when: ( ContextKeyExpr.and(
393
+ ResourceContextKey.HasResource,
394
+ ResourceSelectedForCompareContext,
395
+ isFileOrUntitledResourceContextKey,
396
+ ( WorkbenchListDoubleSelection.toNegated())
397
+ ))
398
+ });
399
+ const selectForCompareCommand = {
400
+ id: SELECT_FOR_COMPARE_COMMAND_ID,
401
+ title: ( localizeWithPath(
402
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
403
+ 'compareSource',
404
+ "Select for Compare"
405
+ ))
406
+ };
407
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
408
+ group: '3_compare',
409
+ order: 30,
410
+ command: selectForCompareCommand,
411
+ when: ( ContextKeyExpr.and(
412
+ ResourceContextKey.HasResource,
413
+ isFileOrUntitledResourceContextKey,
414
+ ( WorkbenchListDoubleSelection.toNegated())
415
+ ))
416
+ });
417
+ const compareSelectedCommand = {
418
+ id: COMPARE_SELECTED_COMMAND_ID,
419
+ title: ( localizeWithPath(
420
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
421
+ 'compareSelected',
422
+ "Compare Selected"
423
+ ))
424
+ };
425
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
426
+ group: '3_compare',
427
+ order: 30,
428
+ command: compareSelectedCommand,
429
+ when: ( ContextKeyExpr.and(
430
+ ResourceContextKey.HasResource,
431
+ WorkbenchListDoubleSelection,
432
+ isFileOrUntitledResourceContextKey
433
+ ))
434
+ });
435
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
436
+ group: '4_close',
437
+ order: 10,
438
+ command: {
439
+ id: CLOSE_EDITOR_COMMAND_ID,
440
+ title: ( localizeWithPath(
441
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
442
+ 'close',
443
+ "Close"
444
+ ))
445
+ },
446
+ when: ( OpenEditorsGroupContext.toNegated())
447
+ });
448
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
449
+ group: '4_close',
450
+ order: 20,
451
+ command: {
452
+ id: CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID,
453
+ title: ( localizeWithPath(
454
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
455
+ 'closeOthers',
456
+ "Close Others"
457
+ ))
458
+ },
459
+ when: ( OpenEditorsGroupContext.toNegated())
460
+ });
461
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
462
+ group: '4_close',
463
+ order: 30,
464
+ command: {
465
+ id: CLOSE_SAVED_EDITORS_COMMAND_ID,
466
+ title: ( localizeWithPath(
467
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
468
+ 'closeSaved',
469
+ "Close Saved"
470
+ ))
471
+ }
472
+ });
473
+ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
474
+ group: '4_close',
475
+ order: 40,
476
+ command: {
477
+ id: CLOSE_EDITORS_IN_GROUP_COMMAND_ID,
478
+ title: ( localizeWithPath(
479
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
480
+ 'closeAll',
481
+ "Close All"
482
+ ))
483
+ }
484
+ });
485
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
486
+ group: 'navigation',
487
+ order: 4,
488
+ command: {
489
+ id: NEW_FILE_COMMAND_ID,
490
+ title: NEW_FILE_LABEL,
491
+ precondition: ExplorerResourceNotReadonlyContext
492
+ },
493
+ when: ExplorerFolderContext
494
+ });
495
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
496
+ group: 'navigation',
497
+ order: 6,
498
+ command: {
499
+ id: NEW_FOLDER_COMMAND_ID,
500
+ title: NEW_FOLDER_LABEL,
501
+ precondition: ExplorerResourceNotReadonlyContext
502
+ },
503
+ when: ExplorerFolderContext
504
+ });
505
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
506
+ group: 'navigation',
507
+ order: 10,
508
+ command: openToSideCommand,
509
+ when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource))
510
+ });
511
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
512
+ group: 'navigation',
513
+ order: 20,
514
+ command: {
515
+ id: OPEN_WITH_EXPLORER_COMMAND_ID,
516
+ title: ( localizeWithPath(
517
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
518
+ 'explorerOpenWith',
519
+ "Open With..."
520
+ )),
521
+ },
522
+ when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ExplorerResourceAvailableEditorIdsContext)),
523
+ });
524
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
525
+ group: '3_compare',
526
+ order: 20,
527
+ command: compareResourceCommand,
528
+ when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, ResourceSelectedForCompareContext, ( WorkbenchListDoubleSelection.toNegated())))
529
+ });
530
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
531
+ group: '3_compare',
532
+ order: 30,
533
+ command: selectForCompareCommand,
534
+ when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, ( WorkbenchListDoubleSelection.toNegated())))
535
+ });
536
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
537
+ group: '3_compare',
538
+ order: 30,
539
+ command: compareSelectedCommand,
540
+ when: ( ContextKeyExpr.and(( ExplorerFolderContext.toNegated()), ResourceContextKey.HasResource, WorkbenchListDoubleSelection))
541
+ });
542
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
543
+ group: '5_cutcopypaste',
544
+ order: 8,
545
+ command: {
546
+ id: CUT_FILE_ID,
547
+ title: ( localizeWithPath(
548
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
549
+ 'cut',
550
+ "Cut"
551
+ ))
552
+ },
553
+ when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ExplorerResourceNotReadonlyContext))
554
+ });
555
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
556
+ group: '5_cutcopypaste',
557
+ order: 10,
558
+ command: {
559
+ id: COPY_FILE_ID,
560
+ title: COPY_FILE_LABEL
561
+ },
562
+ when: ( ExplorerRootContext.toNegated())
563
+ });
564
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
565
+ group: '5_cutcopypaste',
566
+ order: 20,
567
+ command: {
568
+ id: PASTE_FILE_ID,
569
+ title: PASTE_FILE_LABEL,
570
+ precondition: ( ContextKeyExpr.and(ExplorerResourceNotReadonlyContext, FileCopiedContext))
571
+ },
572
+ when: ExplorerFolderContext
573
+ });
574
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, ({
575
+ group: '5b_importexport',
576
+ order: 10,
577
+ command: {
578
+ id: DOWNLOAD_COMMAND_ID,
579
+ title: DOWNLOAD_LABEL
580
+ },
581
+ when: ( ContextKeyExpr.or((
582
+ ContextKeyExpr.and(( IsWebContext.toNegated()), ( ResourceContextKey.Scheme.notEqualsTo(Schemas.file)))), (
583
+ ContextKeyExpr.and(IsWebContext, ( ExplorerFolderContext.toNegated()), ( ExplorerRootContext.toNegated()))), (
584
+ ContextKeyExpr.and(IsWebContext, HasWebFileSystemAccess))))
585
+ }));
586
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, ({
587
+ group: '5b_importexport',
588
+ order: 20,
589
+ command: {
590
+ id: UPLOAD_COMMAND_ID,
591
+ title: UPLOAD_LABEL,
592
+ },
593
+ when: ( ContextKeyExpr.and(
594
+ IsWebContext,
595
+ ExplorerFolderContext,
596
+ ExplorerResourceNotReadonlyContext))
597
+ }));
598
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
599
+ group: '6_copypath',
600
+ order: 10,
601
+ command: copyPathCommand,
602
+ when: ResourceContextKey.IsFileSystemResource
603
+ });
604
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
605
+ group: '6_copypath',
606
+ order: 20,
607
+ command: copyRelativePathCommand,
608
+ when: ResourceContextKey.IsFileSystemResource
609
+ });
610
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
611
+ group: '2_workspace',
612
+ order: 10,
613
+ command: {
614
+ id: ADD_ROOT_FOLDER_COMMAND_ID,
615
+ title: ADD_ROOT_FOLDER_LABEL
616
+ },
617
+ when: ( ContextKeyExpr.and(ExplorerRootContext, ( ContextKeyExpr.or(EnterMultiRootWorkspaceSupportContext, ( WorkbenchStateContext.isEqualTo('workspace'))))))
618
+ });
619
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
620
+ group: '2_workspace',
621
+ order: 30,
622
+ command: {
623
+ id: REMOVE_ROOT_FOLDER_COMMAND_ID,
624
+ title: REMOVE_ROOT_FOLDER_LABEL
625
+ },
626
+ when: ( ContextKeyExpr.and(ExplorerRootContext, ExplorerFolderContext, ( ContextKeyExpr.and(( WorkspaceFolderCountContext.notEqualsTo('0')), ( ContextKeyExpr.or(EnterMultiRootWorkspaceSupportContext, ( WorkbenchStateContext.isEqualTo('workspace'))))))))
627
+ });
628
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
629
+ group: '7_modification',
630
+ order: 10,
631
+ command: {
632
+ id: RENAME_ID,
633
+ title: TRIGGER_RENAME_LABEL,
634
+ precondition: ExplorerResourceNotReadonlyContext
635
+ },
636
+ when: ( ExplorerRootContext.toNegated())
637
+ });
638
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
639
+ group: '7_modification',
640
+ order: 20,
641
+ command: {
642
+ id: MOVE_FILE_TO_TRASH_ID,
643
+ title: MOVE_FILE_TO_TRASH_LABEL,
644
+ precondition: ExplorerResourceNotReadonlyContext
645
+ },
646
+ alt: {
647
+ id: DELETE_FILE_ID,
648
+ title: ( localizeWithPath(
649
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
650
+ 'deleteFile',
651
+ "Delete Permanently"
652
+ )),
653
+ precondition: ExplorerResourceNotReadonlyContext
654
+ },
655
+ when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ExplorerResourceMoveableToTrash))
656
+ });
657
+ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
658
+ group: '7_modification',
659
+ order: 20,
660
+ command: {
661
+ id: DELETE_FILE_ID,
662
+ title: ( localizeWithPath(
663
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
664
+ 'deleteFile',
665
+ "Delete Permanently"
666
+ )),
667
+ precondition: ExplorerResourceNotReadonlyContext
668
+ },
669
+ when: ( ContextKeyExpr.and(( ExplorerRootContext.toNegated()), ( ExplorerResourceMoveableToTrash.toNegated())))
670
+ });
671
+ for (const menuId of [MenuId.EmptyEditorGroupContext, MenuId.EditorTabsBarContext]) {
672
+ MenuRegistry.appendMenuItem(menuId, { command: { id: NEW_UNTITLED_FILE_COMMAND_ID, title: ( localizeWithPath(
673
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
674
+ 'newFile',
675
+ "New Text File"
676
+ )) }, group: '1_file', order: 10 });
677
+ MenuRegistry.appendMenuItem(menuId, { command: { id: 'workbench.action.quickOpen', title: ( localizeWithPath(
678
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
679
+ 'openFile',
680
+ "Open File..."
681
+ )) }, group: '1_file', order: 20 });
682
+ }
683
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
684
+ group: '1_new',
685
+ command: {
686
+ id: NEW_UNTITLED_FILE_COMMAND_ID,
687
+ title: ( localizeWithPath(
688
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
689
+ { key: 'miNewFile', comment: ['&& denotes a mnemonic'] },
690
+ "&&New Text File"
691
+ ))
692
+ },
693
+ order: 1
694
+ });
695
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
696
+ group: '4_save',
697
+ command: {
698
+ id: SAVE_FILE_COMMAND_ID,
699
+ title: ( localizeWithPath(
700
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
701
+ { key: 'miSave', comment: ['&& denotes a mnemonic'] },
702
+ "&&Save"
703
+ )),
704
+ precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
705
+ },
706
+ order: 1
707
+ });
708
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
709
+ group: '4_save',
710
+ command: {
711
+ id: SAVE_FILE_AS_COMMAND_ID,
712
+ title: ( localizeWithPath(
713
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
714
+ { key: 'miSaveAs', comment: ['&& denotes a mnemonic'] },
715
+ "Save &&As..."
716
+ )),
717
+ precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
718
+ },
719
+ order: 2
720
+ });
721
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
722
+ group: '4_save',
723
+ command: {
724
+ id: SAVE_ALL_COMMAND_ID,
725
+ title: ( localizeWithPath(
726
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
727
+ { key: 'miSaveAll', comment: ['&& denotes a mnemonic'] },
728
+ "Save A&&ll"
729
+ )),
730
+ precondition: DirtyWorkingCopiesContext
731
+ },
732
+ order: 3
733
+ });
734
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
735
+ group: '5_autosave',
736
+ command: {
737
+ id: ToggleAutoSaveAction.ID,
738
+ title: ( localizeWithPath(
739
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
740
+ { key: 'miAutoSave', comment: ['&& denotes a mnemonic'] },
741
+ "A&&uto Save"
742
+ )),
743
+ toggled: ( ContextKeyExpr.notEquals('config.files.autoSave', 'off'))
744
+ },
745
+ order: 1
746
+ });
747
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
748
+ group: '6_close',
749
+ command: {
750
+ id: REVERT_FILE_COMMAND_ID,
751
+ title: ( localizeWithPath(
752
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
753
+ { key: 'miRevert', comment: ['&& denotes a mnemonic'] },
754
+ "Re&&vert File"
755
+ )),
756
+ precondition: ( ContextKeyExpr.or((
757
+ ContextKeyExpr.and(ActiveEditorCanRevertContext)), (
758
+ ContextKeyExpr.and(( ResourceContextKey.Scheme.notEqualsTo(Schemas.untitled)), FoldersViewVisibleContext, SidebarFocusContext)))),
759
+ },
760
+ order: 1
761
+ });
762
+ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
763
+ group: '6_close',
764
+ command: {
765
+ id: CLOSE_EDITOR_COMMAND_ID,
766
+ title: ( localizeWithPath(
767
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
768
+ { key: 'miCloseEditor', comment: ['&& denotes a mnemonic'] },
769
+ "&&Close Editor"
770
+ )),
771
+ precondition: ( ContextKeyExpr.or(ActiveEditorContext, ( ContextKeyExpr.and(FoldersViewVisibleContext, SidebarFocusContext))))
772
+ },
773
+ order: 2
774
+ });
775
+ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
776
+ group: '3_global_nav',
777
+ command: {
778
+ id: 'workbench.action.quickOpen',
779
+ title: ( localizeWithPath(
780
+ 'vs/workbench/contrib/files/browser/fileActions.contribution',
781
+ { key: 'miGotoFile', comment: ['&& denotes a mnemonic'] },
782
+ "Go to &&File..."
783
+ ))
784
+ },
785
+ order: 1
786
+ });
787
+
788
+ export { appendEditorTitleContextMenuItem, appendToCommandPalette };