Skip to content

Commit 09daf88

Browse files
committed
Move remote file dialog local commands to electron browser
Fixes microsoft#80959
1 parent f8c9cc7 commit 09daf88

5 files changed

Lines changed: 79 additions & 67 deletions

File tree

src/vs/workbench/browser/actions/workspaceActions.ts

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
99
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1010
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
1111
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
12-
import { ICommandService, ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
12+
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
1313
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
1414
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
15-
import { Schemas } from 'vs/base/common/network';
16-
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
17-
import { toResource } from 'vs/workbench/common/editor';
18-
import { URI } from 'vs/base/common/uri';
1915
import { MenuRegistry, MenuId, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
2016
import { WorkbenchStateContext, SupportsWorkspacesContext } from 'vs/workbench/browser/contextkeys';
2117
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -40,36 +36,6 @@ export class OpenFileAction extends Action {
4036
}
4137
}
4238

43-
export namespace OpenLocalFileCommand {
44-
export const ID = 'workbench.action.files.openLocalFile';
45-
export const LABEL = nls.localize('openLocalFile', "Open Local File...");
46-
47-
export function handler(): ICommandHandler {
48-
return accessor => {
49-
const dialogService = accessor.get(IFileDialogService);
50-
return dialogService.pickFileAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
51-
};
52-
}
53-
}
54-
55-
export namespace SaveLocalFileCommand {
56-
export const ID = 'workbench.action.files.saveLocalFile';
57-
export const LABEL = nls.localize('saveLocalFile', "Save Local File...");
58-
59-
export function handler(): ICommandHandler {
60-
return accessor => {
61-
const textFileService = accessor.get(ITextFileService);
62-
const editorService = accessor.get(IEditorService);
63-
let resource: URI | undefined = toResource(editorService.activeEditor);
64-
const options: ISaveOptions = { force: true, availableFileSystems: [Schemas.file] };
65-
if (resource) {
66-
return textFileService.saveAs(resource, undefined, options);
67-
}
68-
return Promise.resolve(undefined);
69-
};
70-
}
71-
}
72-
7339
export class OpenFolderAction extends Action {
7440

7541
static readonly ID = 'workbench.action.files.openFolder';
@@ -88,18 +54,6 @@ export class OpenFolderAction extends Action {
8854
}
8955
}
9056

91-
export namespace OpenLocalFolderCommand {
92-
export const ID = 'workbench.action.files.openLocalFolder';
93-
export const LABEL = nls.localize('openLocalFolder', "Open Local Folder...");
94-
95-
export function handler(): ICommandHandler {
96-
return accessor => {
97-
const dialogService = accessor.get(IFileDialogService);
98-
return dialogService.pickFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
99-
};
100-
}
101-
}
102-
10357
export class OpenFileFolderAction extends Action {
10458

10559
static readonly ID = 'workbench.action.files.openFileFolder';
@@ -118,19 +72,6 @@ export class OpenFileFolderAction extends Action {
11872
}
11973
}
12074

121-
export namespace OpenLocalFileFolderCommand {
122-
123-
export const ID = 'workbench.action.files.openLocalFileFolder';
124-
export const LABEL = nls.localize('openLocalFileFolder', "Open Local...");
125-
126-
export function handler(): ICommandHandler {
127-
return accessor => {
128-
const dialogService = accessor.get(IFileDialogService);
129-
return dialogService.pickFileFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
130-
};
131-
}
132-
}
133-
13475
export class OpenWorkspaceAction extends Action {
13576

13677
static readonly ID = 'workbench.action.openWorkspace';

src/vs/workbench/common/actions.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import * as nls from 'vs/nls';
67
import { Registry } from 'vs/platform/registry/common/platform';
78
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
89
import { ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
@@ -119,3 +120,23 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
119120
}
120121
}
121122
});
123+
124+
export namespace OpenLocalFileCommand {
125+
export const ID = 'workbench.action.files.openLocalFile';
126+
export const LABEL = nls.localize('openLocalFile', "Open Local File...");
127+
}
128+
129+
export namespace SaveLocalFileCommand {
130+
export const ID = 'workbench.action.files.saveLocalFile';
131+
export const LABEL = nls.localize('saveLocalFile', "Save Local File...");
132+
}
133+
134+
export namespace OpenLocalFolderCommand {
135+
export const ID = 'workbench.action.files.openLocalFolder';
136+
export const LABEL = nls.localize('openLocalFolder', "Open Local Folder...");
137+
}
138+
139+
export namespace OpenLocalFileFolderCommand {
140+
export const ID = 'workbench.action.files.openLocalFileFolder';
141+
export const LABEL = nls.localize('openLocalFileFolder', "Open Local...");
142+
}

src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
3333
import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
3434
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3535
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
36-
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
37-
import { OpenFileFolderAction, OpenLocalFileFolderCommand, OpenFileAction, OpenFolderAction, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/browser/actions/workspaceActions';
36+
import { IWorkbenchActionRegistry, Extensions as ActionExtensions, OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/common/actions';
37+
import { OpenFileFolderAction, OpenFileAction, OpenFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
3838
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
3939
import { IWindowsService } from 'vs/platform/windows/common/windows';
4040
import { RemoteConnectionState, Deprecated_RemoteAuthorityContext, RemoteFileDialogContext } from 'vs/workbench/browser/contextkeys';
4141
import { IDownloadService } from 'vs/platform/download/common/download';
42+
import * as workspaceActions from 'vs/workbench/electron-browser/actions/workspaceActions';
4243

4344
const WINDOW_ACTIONS_COMMAND_ID = 'remote.showActions';
4445
const CLOSE_REMOTE_COMMAND_ID = 'remote.closeRemote';
@@ -387,7 +388,7 @@ if (isMacintosh) {
387388
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
388389
when: RemoteFileDialogContext,
389390
description: { description: OpenLocalFileFolderCommand.LABEL, args: [] },
390-
handler: OpenLocalFileFolderCommand.handler()
391+
handler: workspaceActions.OpenLocalFileFolderCommand.handler()
391392
});
392393
} else {
393394
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileAction, OpenFileAction.ID, OpenFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'File: Open File...', fileCategory);
@@ -398,15 +399,15 @@ if (isMacintosh) {
398399
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
399400
when: RemoteFileDialogContext,
400401
description: { description: OpenLocalFileCommand.LABEL, args: [] },
401-
handler: OpenLocalFileCommand.handler()
402+
handler: workspaceActions.OpenLocalFileCommand.handler()
402403
});
403404
KeybindingsRegistry.registerCommandAndKeybindingRule({
404405
id: OpenLocalFolderCommand.ID,
405406
weight: KeybindingWeight.WorkbenchContrib,
406407
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_O),
407408
when: RemoteFileDialogContext,
408409
description: { description: OpenLocalFolderCommand.LABEL, args: [] },
409-
handler: OpenLocalFolderCommand.handler()
410+
handler: workspaceActions.OpenLocalFolderCommand.handler()
410411
});
411412
}
412413

@@ -416,5 +417,5 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
416417
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S,
417418
when: RemoteFileDialogContext,
418419
description: { description: SaveLocalFileCommand.LABEL, args: [] },
419-
handler: SaveLocalFileCommand.handler()
420+
handler: workspaceActions.SaveLocalFileCommand.handler()
420421
});

src/vs/workbench/electron-browser/actions/workspaceActions.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common
1111
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
1212
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1313
import { INotificationService } from 'vs/platform/notification/common/notification';
14+
import { ICommandHandler } from 'vs/platform/commands/common/commands';
15+
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
16+
import { Schemas } from 'vs/base/common/network';
17+
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
18+
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
19+
import { toResource } from 'vs/workbench/common/editor';
20+
import { URI } from 'vs/base/common/uri';
1421

1522
export class SaveWorkspaceAsAction extends Action {
1623

@@ -95,3 +102,45 @@ export class CloseWorkspaceAction extends Action {
95102
return this.windowService.closeWorkspace();
96103
}
97104
}
105+
106+
export namespace OpenLocalFileCommand {
107+
export function handler(): ICommandHandler {
108+
return accessor => {
109+
const dialogService = accessor.get(IFileDialogService);
110+
return dialogService.pickFileAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
111+
};
112+
}
113+
}
114+
115+
export namespace SaveLocalFileCommand {
116+
export function handler(): ICommandHandler {
117+
return accessor => {
118+
const textFileService = accessor.get(ITextFileService);
119+
const editorService = accessor.get(IEditorService);
120+
let resource: URI | undefined = toResource(editorService.activeEditor);
121+
const options: ISaveOptions = { force: true, availableFileSystems: [Schemas.file] };
122+
if (resource) {
123+
return textFileService.saveAs(resource, undefined, options);
124+
}
125+
return Promise.resolve(undefined);
126+
};
127+
}
128+
}
129+
130+
export namespace OpenLocalFolderCommand {
131+
export function handler(): ICommandHandler {
132+
return accessor => {
133+
const dialogService = accessor.get(IFileDialogService);
134+
return dialogService.pickFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
135+
};
136+
}
137+
}
138+
139+
export namespace OpenLocalFileFolderCommand {
140+
export function handler(): ICommandHandler {
141+
return accessor => {
142+
const dialogService = accessor.get(IFileDialogService);
143+
return dialogService.pickFileFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
144+
};
145+
}
146+
}

src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
2323
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
2424
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
2525
import { equalsIgnoreCase, format, startsWithIgnoreCase } from 'vs/base/common/strings';
26-
import { OpenLocalFileCommand, OpenLocalFileFolderCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/browser/actions/workspaceActions';
26+
import { OpenLocalFileCommand, OpenLocalFileFolderCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/common/actions';
2727
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2828
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
2929
import { isValidBasename } from 'vs/base/common/extpath';

0 commit comments

Comments
 (0)