diff --git a/src/vs/workbench/common/actions.ts b/src/vs/workbench/common/actions.ts index 7a7b727662c9c0f7ddc9d9ae6b908f3cc2332883..72c8dcaecc7e752c407b214affdc08dce874ee15 100644 --- a/src/vs/workbench/common/actions.ts +++ b/src/vs/workbench/common/actions.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as nls from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands'; @@ -120,23 +119,3 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR } } }); - -export namespace OpenLocalFileCommand { - export const ID = 'workbench.action.files.openLocalFile'; - export const LABEL = nls.localize('openLocalFile', "Open Local File..."); -} - -export namespace SaveLocalFileCommand { - export const ID = 'workbench.action.files.saveLocalFile'; - export const LABEL = nls.localize('saveLocalFile', "Save Local File..."); -} - -export namespace OpenLocalFolderCommand { - export const ID = 'workbench.action.files.openLocalFolder'; - export const LABEL = nls.localize('openLocalFolder', "Open Local Folder..."); -} - -export namespace OpenLocalFileFolderCommand { - export const ID = 'workbench.action.files.openLocalFileFolder'; - export const LABEL = nls.localize('openLocalFileFolder', "Open Local..."); -} diff --git a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts index eefaf76296a6ff6e7ea68f81c33f0b381addcc60..37cae45ace2bb52ba9bcc937bfda5517cf45ff1f 100644 --- a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts @@ -33,13 +33,13 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/ import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; -import { IWorkbenchActionRegistry, Extensions as ActionExtensions, OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/common/actions'; +import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { OpenFileFolderAction, OpenFileAction, OpenFolderAction } from 'vs/workbench/browser/actions/workspaceActions'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { IWindowsService } from 'vs/platform/windows/common/windows'; import { RemoteConnectionState, Deprecated_RemoteAuthorityContext, RemoteFileDialogContext } from 'vs/workbench/browser/contextkeys'; import { IDownloadService } from 'vs/platform/download/common/download'; -import * as workspaceActions from 'vs/workbench/electron-browser/actions/workspaceActions'; +import { OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/services/dialogs/browser/remoteFileDialog'; const WINDOW_ACTIONS_COMMAND_ID = 'remote.showActions'; const CLOSE_REMOTE_COMMAND_ID = 'remote.closeRemote'; @@ -388,7 +388,7 @@ if (isMacintosh) { primary: KeyMod.CtrlCmd | KeyCode.KEY_O, when: RemoteFileDialogContext, description: { description: OpenLocalFileFolderCommand.LABEL, args: [] }, - handler: workspaceActions.OpenLocalFileFolderCommand.handler() + handler: OpenLocalFileFolderCommand.handler() }); } else { registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileAction, OpenFileAction.ID, OpenFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'File: Open File...', fileCategory); @@ -399,7 +399,7 @@ if (isMacintosh) { primary: KeyMod.CtrlCmd | KeyCode.KEY_O, when: RemoteFileDialogContext, description: { description: OpenLocalFileCommand.LABEL, args: [] }, - handler: workspaceActions.OpenLocalFileCommand.handler() + handler: OpenLocalFileCommand.handler() }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: OpenLocalFolderCommand.ID, @@ -407,7 +407,7 @@ if (isMacintosh) { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_O), when: RemoteFileDialogContext, description: { description: OpenLocalFolderCommand.LABEL, args: [] }, - handler: workspaceActions.OpenLocalFolderCommand.handler() + handler: OpenLocalFolderCommand.handler() }); } @@ -417,5 +417,5 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S, when: RemoteFileDialogContext, description: { description: SaveLocalFileCommand.LABEL, args: [] }, - handler: workspaceActions.SaveLocalFileCommand.handler() + handler: SaveLocalFileCommand.handler() }); diff --git a/src/vs/workbench/electron-browser/actions/workspaceActions.ts b/src/vs/workbench/electron-browser/actions/workspaceActions.ts index 0e3d0d43e5c67cc01f45ff5cf4ec048ca517e3a7..c01580637dd6c181f8fe639f17114bcc0b3b8351 100644 --- a/src/vs/workbench/electron-browser/actions/workspaceActions.ts +++ b/src/vs/workbench/electron-browser/actions/workspaceActions.ts @@ -11,13 +11,6 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { ICommandHandler } from 'vs/platform/commands/common/commands'; -import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { Schemas } from 'vs/base/common/network'; -import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles'; -import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { toResource } from 'vs/workbench/common/editor'; -import { URI } from 'vs/base/common/uri'; export class SaveWorkspaceAsAction extends Action { @@ -102,45 +95,3 @@ export class CloseWorkspaceAction extends Action { return this.windowService.closeWorkspace(); } } - -export namespace OpenLocalFileCommand { - export function handler(): ICommandHandler { - return accessor => { - const dialogService = accessor.get(IFileDialogService); - return dialogService.pickFileAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); - }; - } -} - -export namespace SaveLocalFileCommand { - export function handler(): ICommandHandler { - return accessor => { - const textFileService = accessor.get(ITextFileService); - const editorService = accessor.get(IEditorService); - let resource: URI | undefined = toResource(editorService.activeEditor); - const options: ISaveOptions = { force: true, availableFileSystems: [Schemas.file] }; - if (resource) { - return textFileService.saveAs(resource, undefined, options); - } - return Promise.resolve(undefined); - }; - } -} - -export namespace OpenLocalFolderCommand { - export function handler(): ICommandHandler { - return accessor => { - const dialogService = accessor.get(IFileDialogService); - return dialogService.pickFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); - }; - } -} - -export namespace OpenLocalFileFolderCommand { - export function handler(): ICommandHandler { - return accessor => { - const dialogService = accessor.get(IFileDialogService); - return dialogService.pickFileFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); - }; - } -} diff --git a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts index f21dad72cef559ec0bd7094c638d70c97bfb49b6..d042a9539700eeaf685f771e7f0337122dbe88c4 100644 --- a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts +++ b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts @@ -23,7 +23,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { equalsIgnoreCase, format, startsWithIgnoreCase } from 'vs/base/common/strings'; -import { OpenLocalFileCommand, OpenLocalFileFolderCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/common/actions'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment'; import { isValidBasename } from 'vs/base/common/extpath'; @@ -32,6 +31,60 @@ import { Emitter } from 'vs/base/common/event'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { createCancelablePromise, CancelablePromise } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; +import { ICommandHandler } from 'vs/platform/commands/common/commands'; +import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { toResource } from 'vs/workbench/common/editor'; + +export namespace OpenLocalFileCommand { + export const ID = 'workbench.action.files.openLocalFile'; + export const LABEL = nls.localize('openLocalFile', "Open Local File..."); + export function handler(): ICommandHandler { + return accessor => { + const dialogService = accessor.get(IFileDialogService); + return dialogService.pickFileAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); + }; + } +} + +export namespace SaveLocalFileCommand { + export const ID = 'workbench.action.files.saveLocalFile'; + export const LABEL = nls.localize('saveLocalFile', "Save Local File..."); + export function handler(): ICommandHandler { + return accessor => { + const textFileService = accessor.get(ITextFileService); + const editorService = accessor.get(IEditorService); + let resource: URI | undefined = toResource(editorService.activeEditor); + const options: ISaveOptions = { force: true, availableFileSystems: [Schemas.file] }; + if (resource) { + return textFileService.saveAs(resource, undefined, options); + } + return Promise.resolve(undefined); + }; + } +} + +export namespace OpenLocalFolderCommand { + export const ID = 'workbench.action.files.openLocalFolder'; + export const LABEL = nls.localize('openLocalFolder', "Open Local Folder..."); + export function handler(): ICommandHandler { + return accessor => { + const dialogService = accessor.get(IFileDialogService); + return dialogService.pickFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); + }; + } +} + +export namespace OpenLocalFileFolderCommand { + export const ID = 'workbench.action.files.openLocalFileFolder'; + export const LABEL = nls.localize('openLocalFileFolder', "Open Local..."); + export function handler(): ICommandHandler { + return accessor => { + const dialogService = accessor.get(IFileDialogService); + return dialogService.pickFileFolderAndOpen({ forceNewWindow: false, availableFileSystems: [Schemas.file] }); + }; + } +} interface FileQuickPickItem extends IQuickPickItem { uri: URI;