@codingame/monaco-vscode-ac93482b-2178-52df-a200-ba0d1a4963fb-common 20.0.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.
Files changed (22) hide show
  1. package/empty.js +1 -0
  2. package/package.json +50 -0
  3. package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.d.ts +23 -0
  4. package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.js +58 -0
  5. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution._autosave.d.ts +1 -0
  6. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution._autosave.js +5 -0
  7. package/vscode/src/vs/workbench/browser/parts/editor/editorAutoSave.d.ts +42 -0
  8. package/vscode/src/vs/workbench/browser/parts/editor/editorAutoSave.js +222 -0
  9. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.d.ts +32 -0
  10. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +398 -0
  11. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.d.ts +8 -0
  12. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +700 -0
  13. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.d.ts +4 -0
  14. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +474 -0
  15. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._fileEditorFactory.d.ts +1 -0
  16. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._fileEditorFactory.js +15 -0
  17. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.d.ts +1 -0
  18. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +72 -0
  19. package/vscode/src/vs/workbench/services/textfile/common/textEditorService.d.ts +32 -0
  20. package/vscode/src/vs/workbench/services/textfile/common/textEditorService.js +194 -0
  21. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorInput.d.ts +45 -0
  22. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorInput.js +159 -0
@@ -0,0 +1,4 @@
1
+ import { IWindowOpenable, IOpenWindowOptions, IOpenEmptyWindowOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/window/common/window";
2
+ import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
3
+ export declare const openWindowCommand: (accessor: ServicesAccessor, toOpen: IWindowOpenable[], options?: IOpenWindowOptions) => void;
4
+ export declare const newWindowCommand: (accessor: ServicesAccessor, options?: IOpenEmptyWindowOptions) => void;
@@ -0,0 +1,474 @@
1
+
2
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
3
+ import { EditorResourceAccessor, SideBySideEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
4
+ import { isWorkspaceToOpen } from '@codingame/monaco-vscode-api/vscode/vs/platform/window/common/window';
5
+ import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
6
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
7
+ import { UNTITLED_WORKSPACE_NAME } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace';
8
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
9
+ import { ExplorerFocusCondition, FilesExplorerFocusCondition, ExplorerFolderContext, TextFileContentProvider, VIEW_ID, VIEWLET_ID, ExplorerCompressedFocusContext, ExplorerCompressedFirstFocusContext, ExplorerCompressedLastFocusContext } from '@codingame/monaco-vscode-f24e325c-2ce0-5bba-8236-bfc4f53180ab-common/vscode/vs/workbench/contrib/files/common/files';
10
+ import { IClipboardService } from '@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service';
11
+ import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
12
+ import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
13
+ import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
14
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
15
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
16
+ import { KeybindingsRegistry, KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
17
+ import { KeyMod, KeyCode, KeyChord } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
18
+ import { isWindows, isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
19
+ import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
20
+ import { getMultiSelectedResources, getResourceForCommand } from '@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common/vscode/vs/workbench/contrib/files/browser/files';
21
+ import { IExplorerService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/files/browser/files.service';
22
+ import { IWorkspaceEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workspaces/common/workspaceEditing.service';
23
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
24
+ import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
25
+ import { SIDE_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
26
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
27
+ import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
28
+ import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
29
+ import { joinPath, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
30
+ import { dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
31
+ import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
32
+ import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
33
+ import { EditorOpenSource, EditorResolution } from '@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor';
34
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
35
+ import { IPaneCompositePartService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
36
+ import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views';
37
+ import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
38
+ import { OPEN_TO_SIDE_COMMAND_ID, COMPARE_WITH_SAVED_COMMAND_ID, ResourceSelectedForCompareContext, SELECT_FOR_COMPARE_COMMAND_ID, 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, REMOVE_ROOT_FOLDER_COMMAND_ID, PREVIOUS_COMPRESSED_FOLDER, NEXT_COMPRESSED_FOLDER, FIRST_COMPRESSED_FOLDER, LAST_COMPRESSED_FOLDER, NEW_UNTITLED_FILE_LABEL, NEW_UNTITLED_FILE_COMMAND_ID, NEW_FILE_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/files/browser/fileConstants';
39
+ import { IFileDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
40
+ import { RemoveRootFolderAction } from '@codingame/monaco-vscode-f24e325c-2ce0-5bba-8236-bfc4f53180ab-common/vscode/vs/workbench/browser/actions/workspaceActions';
41
+ import { OpenEditorsView } from '@codingame/monaco-vscode-bd0792ac-6043-5ec3-a41a-54ccb922a1f4-common/vscode/vs/workbench/contrib/files/browser/views/openEditorsView';
42
+ import { IListService } from '@codingame/monaco-vscode-api/vscode/vs/platform/list/browser/listService.service';
43
+ import '@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common/vscode/vs/workbench/contrib/files/browser/fileCommands._save';
44
+
45
+ const openWindowCommand = (accessor, toOpen, options) => {
46
+ if (Array.isArray(toOpen)) {
47
+ const hostService = accessor.get(IHostService);
48
+ const environmentService = accessor.get(IEnvironmentService);
49
+ toOpen = ( toOpen.map(openable => {
50
+ if (isWorkspaceToOpen(openable) && openable.workspaceUri.scheme === Schemas.untitled) {
51
+ return {
52
+ workspaceUri: joinPath(environmentService.untitledWorkspacesHome, openable.workspaceUri.path, UNTITLED_WORKSPACE_NAME)
53
+ };
54
+ }
55
+ return openable;
56
+ }));
57
+ hostService.openWindow(toOpen, options);
58
+ }
59
+ };
60
+ const newWindowCommand = (accessor, options) => {
61
+ const hostService = accessor.get(IHostService);
62
+ hostService.openWindow(options);
63
+ };
64
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
65
+ weight: KeybindingWeight.WorkbenchContrib,
66
+ when: ExplorerFocusCondition,
67
+ primary: KeyMod.CtrlCmd | KeyCode.Enter,
68
+ mac: {
69
+ primary: KeyMod.WinCtrl | KeyCode.Enter
70
+ },
71
+ id: OPEN_TO_SIDE_COMMAND_ID, handler: async (accessor, resource) => {
72
+ const editorService = accessor.get(IEditorService);
73
+ const fileService = accessor.get(IFileService);
74
+ const explorerService = accessor.get(IExplorerService);
75
+ const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService, accessor.get(IEditorGroupsService), explorerService);
76
+ if (resources.length) {
77
+ const untitledResources = resources.filter(resource => resource.scheme === Schemas.untitled);
78
+ const fileResources = resources.filter(resource => resource.scheme !== Schemas.untitled);
79
+ const items = await Promise.all(( fileResources.map(async (resource) => {
80
+ const item = explorerService.findClosest(resource);
81
+ if (item) {
82
+ return item;
83
+ }
84
+ return await fileService.stat(resource);
85
+ })));
86
+ const files = items.filter(i => !i.isDirectory);
87
+ const editors = ( files.map(f => ({
88
+ resource: f.resource,
89
+ options: { pinned: true }
90
+ }))).concat(...( untitledResources.map(
91
+ untitledResource => ({ resource: untitledResource, options: { pinned: true } })
92
+ )));
93
+ await editorService.openEditors(editors, SIDE_GROUP);
94
+ }
95
+ }
96
+ });
97
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
98
+ weight: KeybindingWeight.WorkbenchContrib + 10,
99
+ when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ( ExplorerFolderContext.toNegated()))),
100
+ primary: KeyCode.Enter,
101
+ mac: {
102
+ primary: KeyMod.CtrlCmd | KeyCode.DownArrow
103
+ },
104
+ id: 'explorer.openAndPassFocus', handler: async (accessor, _resource) => {
105
+ const editorService = accessor.get(IEditorService);
106
+ const explorerService = accessor.get(IExplorerService);
107
+ const resources = explorerService.getContext(true);
108
+ if (resources.length) {
109
+ await editorService.openEditors(( resources.map(
110
+ r => ({ resource: r.resource, options: { preserveFocus: false, pinned: true } })
111
+ )));
112
+ }
113
+ }
114
+ });
115
+ const COMPARE_WITH_SAVED_SCHEMA = 'showModifications';
116
+ let providerDisposables = [];
117
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
118
+ id: COMPARE_WITH_SAVED_COMMAND_ID,
119
+ when: undefined,
120
+ weight: KeybindingWeight.WorkbenchContrib,
121
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyD),
122
+ handler: async (accessor, resource) => {
123
+ const instantiationService = accessor.get(IInstantiationService);
124
+ const textModelService = accessor.get(ITextModelService);
125
+ const editorService = accessor.get(IEditorService);
126
+ const fileService = accessor.get(IFileService);
127
+ const listService = accessor.get(IListService);
128
+ let registerEditorListener = false;
129
+ if (providerDisposables.length === 0) {
130
+ registerEditorListener = true;
131
+ const provider = instantiationService.createInstance(TextFileContentProvider);
132
+ providerDisposables.push(provider);
133
+ providerDisposables.push(textModelService.registerTextModelContentProvider(COMPARE_WITH_SAVED_SCHEMA, provider));
134
+ }
135
+ const uri = getResourceForCommand(resource, editorService, listService);
136
+ if (uri && fileService.hasProvider(uri)) {
137
+ const name = basename(uri);
138
+ const editorLabel = ( localize(7412, "{0} (in file) ↔ {1}", name, name));
139
+ try {
140
+ await TextFileContentProvider.open(uri, COMPARE_WITH_SAVED_SCHEMA, editorLabel, editorService, { pinned: true });
141
+ if (registerEditorListener) {
142
+ providerDisposables.push(editorService.onDidVisibleEditorsChange(() => {
143
+ if (!( editorService.editors.some(
144
+ editor => !!EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: COMPARE_WITH_SAVED_SCHEMA })
145
+ ))) {
146
+ providerDisposables = dispose(providerDisposables);
147
+ }
148
+ }));
149
+ }
150
+ }
151
+ catch {
152
+ providerDisposables = dispose(providerDisposables);
153
+ }
154
+ }
155
+ }
156
+ });
157
+ let globalResourceToCompare;
158
+ let resourceSelectedForCompareContext;
159
+ CommandsRegistry.registerCommand({
160
+ id: SELECT_FOR_COMPARE_COMMAND_ID,
161
+ handler: (accessor, resource) => {
162
+ globalResourceToCompare = getResourceForCommand(resource, accessor.get(IEditorService), accessor.get(IListService));
163
+ if (!resourceSelectedForCompareContext) {
164
+ resourceSelectedForCompareContext = ResourceSelectedForCompareContext.bindTo(accessor.get(IContextKeyService));
165
+ }
166
+ resourceSelectedForCompareContext.set(true);
167
+ }
168
+ });
169
+ CommandsRegistry.registerCommand({
170
+ id: COMPARE_SELECTED_COMMAND_ID,
171
+ handler: async (accessor, resource) => {
172
+ const editorService = accessor.get(IEditorService);
173
+ const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService, accessor.get(IEditorGroupsService), accessor.get(IExplorerService));
174
+ if (resources.length === 2) {
175
+ return editorService.openEditor({
176
+ original: { resource: resources[0] },
177
+ modified: { resource: resources[1] },
178
+ options: { pinned: true }
179
+ });
180
+ }
181
+ return true;
182
+ }
183
+ });
184
+ CommandsRegistry.registerCommand({
185
+ id: COMPARE_RESOURCE_COMMAND_ID,
186
+ handler: (accessor, resource) => {
187
+ const editorService = accessor.get(IEditorService);
188
+ const rightResource = getResourceForCommand(resource, editorService, accessor.get(IListService));
189
+ if (globalResourceToCompare && rightResource) {
190
+ editorService.openEditor({
191
+ original: { resource: globalResourceToCompare },
192
+ modified: { resource: rightResource },
193
+ options: { pinned: true }
194
+ });
195
+ }
196
+ }
197
+ });
198
+ async function resourcesToClipboard(resources, relative, clipboardService, labelService, configurationService) {
199
+ if (resources.length) {
200
+ const lineDelimiter = isWindows ? '\r\n' : '\n';
201
+ let separator = undefined;
202
+ const copyRelativeOrFullPathSeparatorSection = relative ? 'explorer.copyRelativePathSeparator' : 'explorer.copyPathSeparator';
203
+ const copyRelativeOrFullPathSeparator = configurationService.getValue(copyRelativeOrFullPathSeparatorSection);
204
+ if (copyRelativeOrFullPathSeparator === '/' || copyRelativeOrFullPathSeparator === '\\') {
205
+ separator = copyRelativeOrFullPathSeparator;
206
+ }
207
+ const text = ( resources.map(
208
+ resource => labelService.getUriLabel(resource, { relative, noPrefix: true, separator })
209
+ )).join(lineDelimiter);
210
+ await clipboardService.writeText(text);
211
+ }
212
+ }
213
+ const copyPathCommandHandler = async (accessor, resource) => {
214
+ const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IEditorGroupsService), accessor.get(IExplorerService));
215
+ await resourcesToClipboard(resources, false, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
216
+ };
217
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
218
+ weight: KeybindingWeight.WorkbenchContrib,
219
+ when: ( EditorContextKeys.focus.toNegated()),
220
+ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyC,
221
+ win: {
222
+ primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KeyC
223
+ },
224
+ id: COPY_PATH_COMMAND_ID,
225
+ handler: copyPathCommandHandler
226
+ });
227
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
228
+ weight: KeybindingWeight.WorkbenchContrib,
229
+ when: EditorContextKeys.focus,
230
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyC),
231
+ win: {
232
+ primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KeyC
233
+ },
234
+ id: COPY_PATH_COMMAND_ID,
235
+ handler: copyPathCommandHandler
236
+ });
237
+ const copyRelativePathCommandHandler = async (accessor, resource) => {
238
+ const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IEditorGroupsService), accessor.get(IExplorerService));
239
+ await resourcesToClipboard(resources, true, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
240
+ };
241
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
242
+ weight: KeybindingWeight.WorkbenchContrib,
243
+ when: ( EditorContextKeys.focus.toNegated()),
244
+ primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KeyC,
245
+ win: {
246
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyC)
247
+ },
248
+ id: COPY_RELATIVE_PATH_COMMAND_ID,
249
+ handler: copyRelativePathCommandHandler
250
+ });
251
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
252
+ weight: KeybindingWeight.WorkbenchContrib,
253
+ when: EditorContextKeys.focus,
254
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KeyC),
255
+ win: {
256
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyC)
257
+ },
258
+ id: COPY_RELATIVE_PATH_COMMAND_ID,
259
+ handler: copyRelativePathCommandHandler
260
+ });
261
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
262
+ weight: KeybindingWeight.WorkbenchContrib,
263
+ when: undefined,
264
+ primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyP),
265
+ id: 'workbench.action.files.copyPathOfActiveFile',
266
+ handler: async (accessor) => {
267
+ const editorService = accessor.get(IEditorService);
268
+ const activeInput = editorService.activeEditor;
269
+ const resource = EditorResourceAccessor.getOriginalUri(activeInput, { supportSideBySide: SideBySideEditor.PRIMARY });
270
+ const resources = resource ? [resource] : [];
271
+ await resourcesToClipboard(resources, false, accessor.get(IClipboardService), accessor.get(ILabelService), accessor.get(IConfigurationService));
272
+ }
273
+ });
274
+ CommandsRegistry.registerCommand({
275
+ id: REVEAL_IN_EXPLORER_COMMAND_ID,
276
+ handler: async (accessor, resource) => {
277
+ const viewService = accessor.get(IViewsService);
278
+ const contextService = accessor.get(IWorkspaceContextService);
279
+ const explorerService = accessor.get(IExplorerService);
280
+ const editorService = accessor.get(IEditorService);
281
+ const listService = accessor.get(IListService);
282
+ const uri = getResourceForCommand(resource, editorService, listService);
283
+ if (uri && contextService.isInsideWorkspace(uri)) {
284
+ const explorerView = await viewService.openView(VIEW_ID, false);
285
+ if (explorerView) {
286
+ const oldAutoReveal = explorerView.autoReveal;
287
+ explorerView.autoReveal = false;
288
+ explorerView.setExpanded(true);
289
+ await explorerService.select(uri, 'force');
290
+ explorerView.focus();
291
+ explorerView.autoReveal = oldAutoReveal;
292
+ }
293
+ }
294
+ else {
295
+ const openEditorsView = viewService.getViewWithId(OpenEditorsView.ID);
296
+ if (openEditorsView) {
297
+ openEditorsView.setExpanded(true);
298
+ openEditorsView.focus();
299
+ }
300
+ }
301
+ }
302
+ });
303
+ CommandsRegistry.registerCommand({
304
+ id: OPEN_WITH_EXPLORER_COMMAND_ID,
305
+ handler: async (accessor, resource) => {
306
+ const editorService = accessor.get(IEditorService);
307
+ const listService = accessor.get(IListService);
308
+ const uri = getResourceForCommand(resource, editorService, listService);
309
+ if (uri) {
310
+ return editorService.openEditor({ resource: uri, options: { override: EditorResolution.PICK, source: EditorOpenSource.USER } });
311
+ }
312
+ return undefined;
313
+ }
314
+ });
315
+ CommandsRegistry.registerCommand({
316
+ id: REMOVE_ROOT_FOLDER_COMMAND_ID,
317
+ handler: (accessor, resource) => {
318
+ const contextService = accessor.get(IWorkspaceContextService);
319
+ const uriIdentityService = accessor.get(IUriIdentityService);
320
+ const workspace = contextService.getWorkspace();
321
+ const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IEditorService), accessor.get(IEditorGroupsService), accessor.get(IExplorerService)).filter(resource => ( workspace.folders.some(folder => uriIdentityService.extUri.isEqual(folder.uri, resource)))
322
+ );
323
+ if (resources.length === 0) {
324
+ const commandService = accessor.get(ICommandService);
325
+ return commandService.executeCommand(RemoveRootFolderAction.ID);
326
+ }
327
+ const workspaceEditingService = accessor.get(IWorkspaceEditingService);
328
+ return workspaceEditingService.removeFolders(resources);
329
+ }
330
+ });
331
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
332
+ weight: KeybindingWeight.WorkbenchContrib + 10,
333
+ when: ( ContextKeyExpr.and(
334
+ FilesExplorerFocusCondition,
335
+ ExplorerCompressedFocusContext,
336
+ ( ExplorerCompressedFirstFocusContext.negate())
337
+ )),
338
+ primary: KeyCode.LeftArrow,
339
+ id: PREVIOUS_COMPRESSED_FOLDER,
340
+ handler: accessor => {
341
+ const paneCompositeService = accessor.get(IPaneCompositePartService);
342
+ const viewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
343
+ if (viewlet?.getId() !== VIEWLET_ID) {
344
+ return;
345
+ }
346
+ const explorer = viewlet.getViewPaneContainer();
347
+ const view = explorer.getExplorerView();
348
+ view.previousCompressedStat();
349
+ }
350
+ });
351
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
352
+ weight: KeybindingWeight.WorkbenchContrib + 10,
353
+ when: ( ContextKeyExpr.and(
354
+ FilesExplorerFocusCondition,
355
+ ExplorerCompressedFocusContext,
356
+ ( ExplorerCompressedLastFocusContext.negate())
357
+ )),
358
+ primary: KeyCode.RightArrow,
359
+ id: NEXT_COMPRESSED_FOLDER,
360
+ handler: accessor => {
361
+ const paneCompositeService = accessor.get(IPaneCompositePartService);
362
+ const viewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
363
+ if (viewlet?.getId() !== VIEWLET_ID) {
364
+ return;
365
+ }
366
+ const explorer = viewlet.getViewPaneContainer();
367
+ const view = explorer.getExplorerView();
368
+ view.nextCompressedStat();
369
+ }
370
+ });
371
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
372
+ weight: KeybindingWeight.WorkbenchContrib + 10,
373
+ when: ( ContextKeyExpr.and(
374
+ FilesExplorerFocusCondition,
375
+ ExplorerCompressedFocusContext,
376
+ ( ExplorerCompressedFirstFocusContext.negate())
377
+ )),
378
+ primary: KeyCode.Home,
379
+ id: FIRST_COMPRESSED_FOLDER,
380
+ handler: accessor => {
381
+ const paneCompositeService = accessor.get(IPaneCompositePartService);
382
+ const viewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
383
+ if (viewlet?.getId() !== VIEWLET_ID) {
384
+ return;
385
+ }
386
+ const explorer = viewlet.getViewPaneContainer();
387
+ const view = explorer.getExplorerView();
388
+ view.firstCompressedStat();
389
+ }
390
+ });
391
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
392
+ weight: KeybindingWeight.WorkbenchContrib + 10,
393
+ when: ( ContextKeyExpr.and(
394
+ FilesExplorerFocusCondition,
395
+ ExplorerCompressedFocusContext,
396
+ ( ExplorerCompressedLastFocusContext.negate())
397
+ )),
398
+ primary: KeyCode.End,
399
+ id: LAST_COMPRESSED_FOLDER,
400
+ handler: accessor => {
401
+ const paneCompositeService = accessor.get(IPaneCompositePartService);
402
+ const viewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
403
+ if (viewlet?.getId() !== VIEWLET_ID) {
404
+ return;
405
+ }
406
+ const explorer = viewlet.getViewPaneContainer();
407
+ const view = explorer.getExplorerView();
408
+ view.lastCompressedStat();
409
+ }
410
+ });
411
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
412
+ weight: KeybindingWeight.WorkbenchContrib,
413
+ when: null,
414
+ primary: isWeb ? (isWindows ? KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyN) : KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyN) : KeyMod.CtrlCmd | KeyCode.KeyN,
415
+ secondary: isWeb ? [KeyMod.CtrlCmd | KeyCode.KeyN] : undefined,
416
+ id: NEW_UNTITLED_FILE_COMMAND_ID,
417
+ metadata: {
418
+ description: NEW_UNTITLED_FILE_LABEL,
419
+ args: [
420
+ {
421
+ isOptional: true,
422
+ name: 'New Untitled Text File arguments',
423
+ description: 'The editor view type or language ID if known',
424
+ schema: {
425
+ 'type': 'object',
426
+ 'properties': {
427
+ 'viewType': {
428
+ 'type': 'string'
429
+ },
430
+ 'languageId': {
431
+ 'type': 'string'
432
+ }
433
+ }
434
+ }
435
+ }
436
+ ]
437
+ },
438
+ handler: async (accessor, args) => {
439
+ const editorService = accessor.get(IEditorService);
440
+ await editorService.openEditor({
441
+ resource: undefined,
442
+ options: {
443
+ override: args?.viewType,
444
+ pinned: true
445
+ },
446
+ languageId: args?.languageId,
447
+ });
448
+ }
449
+ });
450
+ CommandsRegistry.registerCommand({
451
+ id: NEW_FILE_COMMAND_ID,
452
+ handler: async (accessor, args) => {
453
+ const editorService = accessor.get(IEditorService);
454
+ const dialogService = accessor.get(IFileDialogService);
455
+ const fileService = accessor.get(IFileService);
456
+ const createFileLocalized = ( localize(7413, "Create File"));
457
+ const defaultFileUri = joinPath(await dialogService.defaultFilePath(), args?.fileName ?? 'Untitled.txt');
458
+ const saveUri = await dialogService.showSaveDialog({ saveLabel: createFileLocalized, title: createFileLocalized, defaultUri: defaultFileUri });
459
+ if (!saveUri) {
460
+ return;
461
+ }
462
+ await fileService.createFile(saveUri, undefined, { overwrite: true });
463
+ await editorService.openEditor({
464
+ resource: saveUri,
465
+ options: {
466
+ override: args?.viewType,
467
+ pinned: true
468
+ },
469
+ languageId: args?.languageId,
470
+ });
471
+ }
472
+ });
473
+
474
+ export { newWindowCommand, openWindowCommand };
@@ -0,0 +1,15 @@
1
+
2
+ import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
3
+ import { EditorExtensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
4
+ import { FILE_EDITOR_INPUT_ID } from '@codingame/monaco-vscode-f24e325c-2ce0-5bba-8236-bfc4f53180ab-common/vscode/vs/workbench/contrib/files/common/files';
5
+ import { FileEditorInput } from '@codingame/monaco-vscode-72a1b7d3-3f58-5545-9b7e-f579bd003081-common/vscode/vs/workbench/contrib/files/browser/editors/fileEditorInput';
6
+
7
+ ( Registry.as(EditorExtensions.EditorFactory)).registerFileEditorFactory({
8
+ typeId: FILE_EDITOR_INPUT_ID,
9
+ createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService) => {
10
+ return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);
11
+ },
12
+ isFileEditor: (obj) => {
13
+ return obj instanceof FileEditorInput;
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const PreventDefaultContextMenuItemsContextKeyName = "preventDefaultContextMenuItems";
@@ -0,0 +1,72 @@
1
+
2
+ import { getActiveElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
3
+ import { UndoCommand, RedoCommand, SelectAllCommand } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
4
+ import { CopyAction, PasteAction, CutAction } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/clipboard/browser/clipboard';
5
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
6
+ import { MenuRegistry, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
7
+ import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
8
+ import { IWebviewService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/webview/browser/webview.service';
9
+ import { WebviewInput } from '@codingame/monaco-vscode-670aae94-7f88-54d7-90ea-6fcbef423557-common/vscode/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput';
10
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
11
+
12
+ const PRIORITY = 100;
13
+ function overrideCommandForWebview(command, f) {
14
+ command?.addImplementation(PRIORITY, 'webview', accessor => {
15
+ const webviewService = accessor.get(IWebviewService);
16
+ const webview = webviewService.activeWebview;
17
+ if (webview?.isFocused) {
18
+ f(webview);
19
+ return true;
20
+ }
21
+ if (getActiveElement()?.classList.contains('action-menu-item')) {
22
+ const editorService = accessor.get(IEditorService);
23
+ if (editorService.activeEditor instanceof WebviewInput) {
24
+ f(editorService.activeEditor.webview);
25
+ return true;
26
+ }
27
+ }
28
+ return false;
29
+ });
30
+ }
31
+ overrideCommandForWebview(UndoCommand, webview => webview.undo());
32
+ overrideCommandForWebview(RedoCommand, webview => webview.redo());
33
+ overrideCommandForWebview(SelectAllCommand, webview => webview.selectAll());
34
+ overrideCommandForWebview(CopyAction, webview => webview.copy());
35
+ overrideCommandForWebview(PasteAction, webview => webview.paste());
36
+ overrideCommandForWebview(CutAction, webview => webview.cut());
37
+ const PreventDefaultContextMenuItemsContextKeyName = 'preventDefaultContextMenuItems';
38
+ if (CutAction) {
39
+ MenuRegistry.appendMenuItem(MenuId.WebviewContext, {
40
+ command: {
41
+ id: CutAction.id,
42
+ title: ( localize(12276, "Cut")),
43
+ },
44
+ group: '5_cutcopypaste',
45
+ order: 1,
46
+ when: ContextKeyExpr.not(PreventDefaultContextMenuItemsContextKeyName),
47
+ });
48
+ }
49
+ if (CopyAction) {
50
+ MenuRegistry.appendMenuItem(MenuId.WebviewContext, {
51
+ command: {
52
+ id: CopyAction.id,
53
+ title: ( localize(12277, "Copy")),
54
+ },
55
+ group: '5_cutcopypaste',
56
+ order: 2,
57
+ when: ContextKeyExpr.not(PreventDefaultContextMenuItemsContextKeyName),
58
+ });
59
+ }
60
+ if (PasteAction) {
61
+ MenuRegistry.appendMenuItem(MenuId.WebviewContext, {
62
+ command: {
63
+ id: PasteAction.id,
64
+ title: ( localize(12278, "Paste")),
65
+ },
66
+ group: '5_cutcopypaste',
67
+ order: 3,
68
+ when: ContextKeyExpr.not(PreventDefaultContextMenuItemsContextKeyName),
69
+ });
70
+ }
71
+
72
+ export { PreventDefaultContextMenuItemsContextKeyName };
@@ -0,0 +1,32 @@
1
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
2
+ import { IFileEditorInput, IUntypedEditorInput, IUntypedFileEditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
3
+ import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
4
+ import { IUntitledTextEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/untitled/common/untitledTextEditorService.service";
5
+ import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
6
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
7
+ import { IEditorResolverService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorResolverService.service";
8
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
9
+ import { ITextEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textEditorService.service";
10
+ export declare class TextEditorService extends Disposable implements ITextEditorService {
11
+ private readonly untitledTextEditorService;
12
+ private readonly instantiationService;
13
+ private readonly uriIdentityService;
14
+ private readonly fileService;
15
+ private readonly editorResolverService;
16
+ readonly _serviceBrand: undefined;
17
+ private readonly editorInputCache;
18
+ private readonly fileEditorFactory;
19
+ constructor(untitledTextEditorService: IUntitledTextEditorService, instantiationService: IInstantiationService, uriIdentityService: IUriIdentityService, fileService: IFileService, editorResolverService: IEditorResolverService);
20
+ private registerDefaultEditor;
21
+ resolveTextEditor(input: IUntypedEditorInput): Promise<EditorInput>;
22
+ resolveTextEditor(input: IUntypedFileEditorInput): Promise<IFileEditorInput>;
23
+ createTextEditor(input: IUntypedEditorInput): EditorInput;
24
+ createTextEditor(input: IUntypedFileEditorInput): IFileEditorInput;
25
+ private createOrGetCached;
26
+ private static readonly LEAK_TRACKING_THRESHOLD;
27
+ private static readonly LEAK_REPORTING_THRESHOLD;
28
+ private static LEAK_REPORTED;
29
+ private readonly mapLeakToCounter;
30
+ private trackLeaks;
31
+ private untrackLeaks;
32
+ }