Skip to content

Commit 96bf508

Browse files
committed
Move remote dialog local commands into remoteFileDialog.ts
Fixes microsoft#80959
1 parent 09daf88 commit 96bf508

4 files changed

Lines changed: 60 additions & 77 deletions

File tree

src/vs/workbench/common/actions.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
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';
76
import { Registry } from 'vs/platform/registry/common/platform';
87
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
98
import { ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
@@ -120,23 +119,3 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
120119
}
121120
}
122121
});
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +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, OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/common/actions';
36+
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
3737
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';
42+
import { OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/services/dialogs/browser/remoteFileDialog';
4343

4444
const WINDOW_ACTIONS_COMMAND_ID = 'remote.showActions';
4545
const CLOSE_REMOTE_COMMAND_ID = 'remote.closeRemote';
@@ -388,7 +388,7 @@ if (isMacintosh) {
388388
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
389389
when: RemoteFileDialogContext,
390390
description: { description: OpenLocalFileFolderCommand.LABEL, args: [] },
391-
handler: workspaceActions.OpenLocalFileFolderCommand.handler()
391+
handler: OpenLocalFileFolderCommand.handler()
392392
});
393393
} else {
394394
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileAction, OpenFileAction.ID, OpenFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'File: Open File...', fileCategory);
@@ -399,15 +399,15 @@ if (isMacintosh) {
399399
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
400400
when: RemoteFileDialogContext,
401401
description: { description: OpenLocalFileCommand.LABEL, args: [] },
402-
handler: workspaceActions.OpenLocalFileCommand.handler()
402+
handler: OpenLocalFileCommand.handler()
403403
});
404404
KeybindingsRegistry.registerCommandAndKeybindingRule({
405405
id: OpenLocalFolderCommand.ID,
406406
weight: KeybindingWeight.WorkbenchContrib,
407407
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_O),
408408
when: RemoteFileDialogContext,
409409
description: { description: OpenLocalFolderCommand.LABEL, args: [] },
410-
handler: workspaceActions.OpenLocalFolderCommand.handler()
410+
handler: OpenLocalFolderCommand.handler()
411411
});
412412
}
413413

@@ -417,5 +417,5 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
417417
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S,
418418
when: RemoteFileDialogContext,
419419
description: { description: SaveLocalFileCommand.LABEL, args: [] },
420-
handler: workspaceActions.SaveLocalFileCommand.handler()
420+
handler: SaveLocalFileCommand.handler()
421421
});

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

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ 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';
2114

2215
export class SaveWorkspaceAsAction extends Action {
2316

@@ -102,45 +95,3 @@ export class CloseWorkspaceAction extends Action {
10295
return this.windowService.closeWorkspace();
10396
}
10497
}
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: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ 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/common/actions';
2726
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2827
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
2928
import { isValidBasename } from 'vs/base/common/extpath';
@@ -32,6 +31,60 @@ import { Emitter } from 'vs/base/common/event';
3231
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
3332
import { createCancelablePromise, CancelablePromise } from 'vs/base/common/async';
3433
import { CancellationToken } from 'vs/base/common/cancellation';
34+
import { ICommandHandler } from 'vs/platform/commands/common/commands';
35+
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
36+
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
37+
import { toResource } from 'vs/workbench/common/editor';
38+
39+
export namespace OpenLocalFileCommand {
40+
export const ID = 'workbench.action.files.openLocalFile';
41+
export const LABEL = nls.localize('openLocalFile', "Open Local File...");
42+
export function handler(): ICommandHandler {
43+
return accessor => {
44+
const dialogService = accessor.get(IFileDialogService);
45+
return dialogService.pickFileAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
46+
};
47+
}
48+
}
49+
50+
export namespace SaveLocalFileCommand {
51+
export const ID = 'workbench.action.files.saveLocalFile';
52+
export const LABEL = nls.localize('saveLocalFile', "Save Local File...");
53+
export function handler(): ICommandHandler {
54+
return accessor => {
55+
const textFileService = accessor.get(ITextFileService);
56+
const editorService = accessor.get(IEditorService);
57+
let resource: URI | undefined = toResource(editorService.activeEditor);
58+
const options: ISaveOptions = { force: true, availableFileSystems: [Schemas.file] };
59+
if (resource) {
60+
return textFileService.saveAs(resource, undefined, options);
61+
}
62+
return Promise.resolve(undefined);
63+
};
64+
}
65+
}
66+
67+
export namespace OpenLocalFolderCommand {
68+
export const ID = 'workbench.action.files.openLocalFolder';
69+
export const LABEL = nls.localize('openLocalFolder', "Open Local Folder...");
70+
export function handler(): ICommandHandler {
71+
return accessor => {
72+
const dialogService = accessor.get(IFileDialogService);
73+
return dialogService.pickFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
74+
};
75+
}
76+
}
77+
78+
export namespace OpenLocalFileFolderCommand {
79+
export const ID = 'workbench.action.files.openLocalFileFolder';
80+
export const LABEL = nls.localize('openLocalFileFolder', "Open Local...");
81+
export function handler(): ICommandHandler {
82+
return accessor => {
83+
const dialogService = accessor.get(IFileDialogService);
84+
return dialogService.pickFileFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] });
85+
};
86+
}
87+
}
3588

3689
interface FileQuickPickItem extends IQuickPickItem {
3790
uri: URI;

0 commit comments

Comments
 (0)