mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Move remote file dialog local commands to electron browser
Fixes #80959
This commit is contained in:
@@ -9,13 +9,9 @@ import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICommandService, ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
|
||||
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 { toResource } from 'vs/workbench/common/editor';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MenuRegistry, MenuId, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { WorkbenchStateContext, SupportsWorkspacesContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -40,36 +36,6 @@ export class OpenFileAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
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 class OpenFolderAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.files.openFolder';
|
||||
@@ -88,18 +54,6 @@ export class OpenFolderAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
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 class OpenFileFolderAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.files.openFileFolder';
|
||||
@@ -118,19 +72,6 @@ export class OpenFileFolderAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
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] });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenWorkspaceAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.openWorkspace';
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* 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';
|
||||
@@ -119,3 +120,23 @@ 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...");
|
||||
}
|
||||
|
||||
@@ -33,12 +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 } from 'vs/workbench/common/actions';
|
||||
import { OpenFileFolderAction, OpenLocalFileFolderCommand, OpenFileAction, OpenFolderAction, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/browser/actions/workspaceActions';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions, OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } 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';
|
||||
|
||||
const WINDOW_ACTIONS_COMMAND_ID = 'remote.showActions';
|
||||
const CLOSE_REMOTE_COMMAND_ID = 'remote.closeRemote';
|
||||
@@ -387,7 +388,7 @@ if (isMacintosh) {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
|
||||
when: RemoteFileDialogContext,
|
||||
description: { description: OpenLocalFileFolderCommand.LABEL, args: [] },
|
||||
handler: OpenLocalFileFolderCommand.handler()
|
||||
handler: workspaceActions.OpenLocalFileFolderCommand.handler()
|
||||
});
|
||||
} else {
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenFileAction, OpenFileAction.ID, OpenFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_O }), 'File: Open File...', fileCategory);
|
||||
@@ -398,7 +399,7 @@ if (isMacintosh) {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_O,
|
||||
when: RemoteFileDialogContext,
|
||||
description: { description: OpenLocalFileCommand.LABEL, args: [] },
|
||||
handler: OpenLocalFileCommand.handler()
|
||||
handler: workspaceActions.OpenLocalFileCommand.handler()
|
||||
});
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: OpenLocalFolderCommand.ID,
|
||||
@@ -406,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: OpenLocalFolderCommand.handler()
|
||||
handler: workspaceActions.OpenLocalFolderCommand.handler()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -416,5 +417,5 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S,
|
||||
when: RemoteFileDialogContext,
|
||||
description: { description: SaveLocalFileCommand.LABEL, args: [] },
|
||||
handler: SaveLocalFileCommand.handler()
|
||||
handler: workspaceActions.SaveLocalFileCommand.handler()
|
||||
});
|
||||
|
||||
@@ -11,6 +11,13 @@ 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 {
|
||||
|
||||
@@ -95,3 +102,45 @@ 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] });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ 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/browser/actions/workspaceActions';
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user