mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 817eb6b0c720a4ecbc13c020afbbebfed667aa09 (#7356)
This commit is contained in:
@@ -4,20 +4,21 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
|
||||
export class ToggleDevToolsAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.toggleDevTools';
|
||||
static LABEL = nls.localize('toggleDevTools', "Toggle Developer Tools");
|
||||
|
||||
constructor(id: string, label: string, @IWindowService private readonly windowsService: IWindowService) {
|
||||
constructor(id: string, label: string, @IElectronService private readonly electronService: IElectronService) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
return this.windowsService.toggleDevTools();
|
||||
return this.electronService.toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +27,11 @@ export class ToggleSharedProcessAction extends Action {
|
||||
static readonly ID = 'workbench.action.toggleSharedProcess';
|
||||
static LABEL = nls.localize('toggleSharedProcess', "Toggle Shared Process");
|
||||
|
||||
constructor(id: string, label: string, @IWindowsService private readonly windowsService: IWindowsService) {
|
||||
constructor(id: string, label: string, @ISharedProcessService private readonly sharedProcessService: ISharedProcessService) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
return this.windowsService.toggleSharedProcess();
|
||||
return this.sharedProcessService.toggleSharedProcessWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,38 +18,25 @@ import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
|
||||
import { ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
|
||||
export class CloseCurrentWindowAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.closeWindow';
|
||||
static readonly LABEL = nls.localize('closeWindow', "Close Window");
|
||||
|
||||
constructor(id: string, label: string, @IWindowService private readonly windowService: IWindowService) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
this.windowService.closeWindow();
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
export class NewWindowAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.newWindow';
|
||||
static LABEL = nls.localize('newWindow', "New Window");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowsService private readonly windowsService: IWindowsService
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
return this.windowsService.openNewWindow();
|
||||
run(): Promise<boolean> {
|
||||
this.electronService.closeWindow();
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,21 +137,21 @@ export class ZoomResetAction extends BaseZoomAction {
|
||||
}
|
||||
}
|
||||
|
||||
export class ReloadWindowWithExtensionsDisabledAction extends Action {
|
||||
export class RestartWithExtensionsDisabledAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.reloadWindowWithExtensionsDisabled';
|
||||
static LABEL = nls.localize('reloadWindowWithExntesionsDisabled', "Reload Window With Extensions Disabled");
|
||||
static readonly ID = 'workbench.action.restartWithExtensionsDisabled';
|
||||
static LABEL = nls.localize('restartWithExtensionsDisabled', "Restart With Extensions Disabled");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private readonly windowService: IWindowService
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
async run(): Promise<boolean> {
|
||||
await this.windowService.reloadWindow({ _: [], 'disable-extensions': true });
|
||||
await this.electronService.relaunch({ addArgs: ['--disable-extensions'] });
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -186,6 +173,7 @@ export abstract class BaseSwitchWindow extends Action {
|
||||
private keybindingService: IKeybindingService,
|
||||
private modelService: IModelService,
|
||||
private modeService: IModeService,
|
||||
private electronService: IElectronService
|
||||
) {
|
||||
super(id, label);
|
||||
|
||||
@@ -217,7 +205,7 @@ export abstract class BaseSwitchWindow extends Action {
|
||||
placeHolder,
|
||||
quickNavigate: this.isQuickNavigate() ? { keybindings: this.keybindingService.lookupKeybindings(this.id) } : undefined,
|
||||
onDidTriggerItemButton: async context => {
|
||||
await this.windowsService.closeWindow(context.item.payload);
|
||||
await this.electronService.closeWindow();
|
||||
context.removeItem();
|
||||
}
|
||||
});
|
||||
@@ -242,8 +230,9 @@ export class SwitchWindow extends BaseSwitchWindow {
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IElectronService electronService: IElectronService
|
||||
) {
|
||||
super(id, label, windowsService, windowService, quickInputService, keybindingService, modelService, modeService);
|
||||
super(id, label, windowsService, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
}
|
||||
|
||||
protected isQuickNavigate(): boolean {
|
||||
@@ -265,8 +254,9 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IElectronService electronService: IElectronService
|
||||
) {
|
||||
super(id, label, windowsService, windowService, quickInputService, keybindingService, modelService, modeService);
|
||||
super(id, label, windowsService, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
}
|
||||
|
||||
protected isQuickNavigate(): boolean {
|
||||
@@ -275,25 +265,25 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
|
||||
}
|
||||
|
||||
export const NewWindowTabHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).newWindowTab();
|
||||
return accessor.get(IElectronService).newWindowTab();
|
||||
};
|
||||
|
||||
export const ShowPreviousWindowTabHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).showPreviousWindowTab();
|
||||
return accessor.get(IElectronService).showPreviousWindowTab();
|
||||
};
|
||||
|
||||
export const ShowNextWindowTabHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).showNextWindowTab();
|
||||
return accessor.get(IElectronService).showNextWindowTab();
|
||||
};
|
||||
|
||||
export const MoveWindowTabToNewWindowHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).moveWindowTabToNewWindow();
|
||||
return accessor.get(IElectronService).moveWindowTabToNewWindow();
|
||||
};
|
||||
|
||||
export const MergeWindowTabsHandlerHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).mergeAllWindowTabs();
|
||||
return accessor.get(IElectronService).mergeAllWindowTabs();
|
||||
};
|
||||
|
||||
export const ToggleWindowTabsBarHandler: ICommandHandler = function (accessor: ServicesAccessor) {
|
||||
return accessor.get(IWindowsService).toggleWindowTabsBar();
|
||||
return accessor.get(IElectronService).toggleWindowTabsBar();
|
||||
};
|
||||
|
||||
@@ -10,7 +10,6 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
|
||||
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';
|
||||
|
||||
export class SaveWorkspaceAsAction extends Action {
|
||||
|
||||
@@ -69,29 +68,3 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
|
||||
return this.windowService.openWindow([{ workspaceUri: newWorkspace.configPath }], { forceNewWindow: true });
|
||||
}
|
||||
}
|
||||
|
||||
export class CloseWorkspaceAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.closeFolder';
|
||||
static LABEL = nls.localize('closeWorkspace', "Close Workspace");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWindowService private readonly windowService: IWindowService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
this.notificationService.info(nls.localize('noWorkspaceOpened', "There is currently no workspace opened in this instance to close."));
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return this.windowService.closeWorkspace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ import * as os from 'os';
|
||||
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { ToggleSharedProcessAction, ToggleDevToolsAction } from 'vs/workbench/electron-browser/actions/developerActions';
|
||||
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, NewWindowAction, QuickSwitchWindow, ReloadWindowWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-browser/actions/windowActions';
|
||||
import { SaveWorkspaceAsAction, DuplicateWorkspaceInNewWindowAction, CloseWorkspaceAction } from 'vs/workbench/electron-browser/actions/workspaceActions';
|
||||
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, QuickSwitchWindow, RestartWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-browser/actions/windowActions';
|
||||
import { SaveWorkspaceAsAction, DuplicateWorkspaceInNewWindowAction } from 'vs/workbench/electron-browser/actions/workspaceActions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { SupportsWorkspacesContext, IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext, WorkbenchStateContext, WorkspaceFolderCountContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { SupportsWorkspacesContext, IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { NoEditorsVisibleContext, SingleEditorGroupsContext } from 'vs/workbench/common/editor';
|
||||
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
|
||||
import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions'; // {{SQL CARBON EDIT}} add import
|
||||
|
||||
@@ -28,13 +28,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
(function registerActions(): void {
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
||||
// Actions: File
|
||||
(function registerFileActions(): void {
|
||||
const fileCategory = nls.localize('file', "File");
|
||||
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(CloseWorkspaceAction, CloseWorkspaceAction.ID, CloseWorkspaceAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_F) }), 'File: Close Workspace', fileCategory, SupportsWorkspacesContext);
|
||||
})();
|
||||
|
||||
// Actions: View
|
||||
(function registerViewActions(): void {
|
||||
const viewCategory = nls.localize('view', "View");
|
||||
@@ -46,7 +39,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
|
||||
// Actions: Window
|
||||
(function registerWindowActions(): void {
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(NewWindowAction, NewWindowAction.ID, NewWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_N }), 'New Window');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(CloseCurrentWindowAction, CloseCurrentWindowAction.ID, CloseCurrentWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W }), 'Close Window');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(SwitchWindow, SwitchWindow.ID, SwitchWindow.LABEL, { primary: 0, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_W } }), 'Switch Window...');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickSwitchWindow, QuickSwitchWindow.ID, QuickSwitchWindow.LABEL), 'Quick Switch Window...');
|
||||
@@ -57,8 +49,8 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
when: ContextKeyExpr.and(NoEditorsVisibleContext, SingleEditorGroupsContext),
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
|
||||
handler: accessor => {
|
||||
const windowService = accessor.get(IWindowService);
|
||||
windowService.closeWindow();
|
||||
const electronService = accessor.get(IElectronService);
|
||||
electronService.closeWindow();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,8 +58,8 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
id: 'workbench.action.quit',
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
handler(accessor: ServicesAccessor) {
|
||||
const windowsService = accessor.get(IWindowsService);
|
||||
windowsService.quit();
|
||||
const electronService = accessor.get(IElectronService);
|
||||
electronService.quit();
|
||||
},
|
||||
when: undefined,
|
||||
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_Q },
|
||||
@@ -108,7 +100,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
(function registerDeveloperActions(): void {
|
||||
const developerCategory = nls.localize('developer', "Developer");
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleSharedProcessAction, ToggleSharedProcessAction.ID, ToggleSharedProcessAction.LABEL), 'Developer: Toggle Shared Process', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowWithExtensionsDisabledAction, ReloadWindowWithExtensionsDisabledAction.ID, ReloadWindowWithExtensionsDisabledAction.LABEL), 'Developer: Reload Window With Extensions Disabled', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(RestartWithExtensionsDisabledAction, RestartWithExtensionsDisabledAction.ID, RestartWithExtensionsDisabledAction.LABEL), 'Developer: Restart With Extensions Disabled', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL), 'Developer: Toggle Developer Tools', developerCategory);
|
||||
|
||||
KeybindingsRegistry.registerKeybindingRule({
|
||||
@@ -123,24 +115,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
|
||||
// Menu
|
||||
(function registerMenu(): void {
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
group: '1_new',
|
||||
command: {
|
||||
id: NewWindowAction.ID,
|
||||
title: nls.localize({ key: 'miNewWindow', comment: ['&& denotes a mnemonic'] }, "New &&Window")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
// {{SQL CARBON EDIT}} - Add install VSIX menu item
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
group: '5.1_installExtension',
|
||||
command: {
|
||||
id: InstallVSIXAction.ID,
|
||||
title: nls.localize({ key: 'miinstallVsix', comment: ['&& denotes a mnemonic'] }, "Install Extension from VSIX Package")
|
||||
}
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
group: '3_workspace',
|
||||
command: {
|
||||
@@ -151,25 +125,13 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
when: SupportsWorkspacesContext
|
||||
});
|
||||
|
||||
// {{SQL CARBON EDIT}} - Add install VSIX menu item
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
group: '6_close',
|
||||
group: '5.1_installExtension',
|
||||
command: {
|
||||
id: CloseWorkspaceAction.ID,
|
||||
title: nls.localize({ key: 'miCloseFolder', comment: ['&& denotes a mnemonic'] }, "Close &&Folder"),
|
||||
precondition: WorkspaceFolderCountContext.notEqualsTo('0')
|
||||
},
|
||||
order: 3,
|
||||
when: WorkbenchStateContext.notEqualsTo('workspace')
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
group: '6_close',
|
||||
command: {
|
||||
id: CloseWorkspaceAction.ID,
|
||||
title: nls.localize({ key: 'miCloseWorkspace', comment: ['&& denotes a mnemonic'] }, "Close &&Workspace")
|
||||
},
|
||||
order: 3,
|
||||
when: ContextKeyExpr.and(WorkbenchStateContext.isEqualTo('workspace'), SupportsWorkspacesContext)
|
||||
id: InstallVSIXAction.ID,
|
||||
title: nls.localize({ key: 'miinstallVsix', comment: ['&& denotes a mnemonic'] }, "Install Extension from VSIX Package")
|
||||
}
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
|
||||
@@ -53,11 +53,13 @@ import { IPreferencesService } from '../services/preferences/common/preferences'
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IMenubarService, IMenubarData, IMenubarMenu, IMenubarKeybinding, IMenubarMenuItemSubmenu, IMenubarMenuItemAction, MenubarMenuItem } from 'vs/platform/menubar/node/menubar';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IOpenerService, OpenOptions } from 'vs/platform/opener/common/opener';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { posix, dirname } from 'vs/base/common/path';
|
||||
import { getBaseLabel } from 'vs/base/common/labels';
|
||||
import { ITunnelService, extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/remote/common/tunnel';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
|
||||
const TextInputActions: IAction[] = [
|
||||
new Action('undo', nls.localize('undo', "Undo"), undefined, true, () => Promise.resolve(document.execCommand('undo'))),
|
||||
@@ -87,7 +89,6 @@ export class ElectronWindow extends Disposable {
|
||||
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: EditorServiceImpl,
|
||||
@IWindowsService private readonly windowsService: IWindowsService,
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ITitleService private readonly titleService: ITitleService,
|
||||
@@ -108,7 +109,9 @@ export class ElectronWindow extends Disposable {
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
@IElectronService private readonly electronService: IElectronService,
|
||||
@ITunnelService private readonly tunnelService: ITunnelService,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -250,9 +253,28 @@ export class ElectronWindow extends Disposable {
|
||||
this._register(this.trackClosedWaitFiles(waitMarkerFile, resourcesToWaitFor));
|
||||
}
|
||||
|
||||
// macOS custom title menu
|
||||
// macOS OS integration
|
||||
if (isMacintosh) {
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => this.provideCustomTitleContextMenu()));
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => {
|
||||
const file = toResource(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: Schemas.file });
|
||||
|
||||
// Represented Filename
|
||||
this.updateRepresentedFilename(file ? file.fsPath : undefined);
|
||||
|
||||
// Custom title menu
|
||||
this.provideCustomTitleContextMenu(file ? file.fsPath : undefined);
|
||||
}));
|
||||
}
|
||||
|
||||
// Maximize/Restore on doubleclick (for macOS custom title)
|
||||
if (isMacintosh && getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
|
||||
const titlePart = this.layoutService.getContainer(Parts.TITLEBAR_PART);
|
||||
|
||||
this._register(DOM.addDisposableListener(titlePart, DOM.EventType.DBLCLICK, e => {
|
||||
DOM.EventHelper.stop(e);
|
||||
|
||||
this.electronService.handleTitleDoubleClick();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +295,7 @@ export class ElectronWindow extends Disposable {
|
||||
private onAllEditorsClosed(): void {
|
||||
const visibleEditors = this.editorService.visibleControls.length;
|
||||
if (visibleEditors === 0) {
|
||||
this.windowService.closeWindow();
|
||||
this.electronService.closeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,19 +339,21 @@ export class ElectronWindow extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private provideCustomTitleContextMenu(): void {
|
||||
private updateRepresentedFilename(filePath: string | undefined): void {
|
||||
this.electronService.setRepresentedFilename(filePath ? filePath : '');
|
||||
}
|
||||
|
||||
private provideCustomTitleContextMenu(filePath: string | undefined): void {
|
||||
|
||||
// Clear old menu
|
||||
this.customTitleContextMenuDisposable.clear();
|
||||
|
||||
// Provide new menu if a file is opened and we are on a custom title
|
||||
const fileResource = toResource(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: Schemas.file });
|
||||
if (!fileResource || getTitleBarStyle(this.configurationService, this.environmentService) !== 'custom') {
|
||||
if (!filePath || getTitleBarStyle(this.configurationService, this.environmentService) !== 'custom') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Split up filepath into segments
|
||||
const filePath = fileResource.fsPath;
|
||||
const segments = filePath.split(posix.sep);
|
||||
for (let i = segments.length; i > 0; i--) {
|
||||
const isFile = (i === segments.length);
|
||||
@@ -400,26 +424,24 @@ export class ElectronWindow extends Disposable {
|
||||
private setupOpenHandlers(): void {
|
||||
|
||||
// Block window.open() calls
|
||||
const $this = this;
|
||||
window.open = function (): Window | null {
|
||||
throw new Error('Prevented call to window.open(). Use IOpenerService instead!');
|
||||
};
|
||||
|
||||
// Handle internal open() calls
|
||||
this.openerService.registerOpener({
|
||||
async open(resource: URI, options?: { openToSide?: boolean; openExternal?: boolean; } | undefined): Promise<boolean> {
|
||||
open: async (resource: URI, options?: OpenOptions): Promise<boolean> => {
|
||||
|
||||
// If either the caller wants to open externally or the
|
||||
// scheme is one where we prefer to open externally
|
||||
// we handle this resource by delegating the opening to
|
||||
// the main process to prevent window focus issues.
|
||||
const scheme = resource.scheme.toLowerCase();
|
||||
const preferOpenExternal = (scheme === Schemas.mailto || scheme === Schemas.http || scheme === Schemas.https);
|
||||
if ((options && options.openExternal) || preferOpenExternal) {
|
||||
const success = await $this.windowsService.openExternal(encodeURI(resource.toString(true)));
|
||||
if (!success && resource.scheme === Schemas.file) {
|
||||
if (this.shouldOpenExternal(resource, options)) {
|
||||
const { resolved } = await this.openerService.resolveExternalUri(resource, options);
|
||||
const success = await this.electronService.openExternal(encodeURI(resolved.toString(true)));
|
||||
if (!success && resolved.scheme === Schemas.file) {
|
||||
// if opening failed, and this is a file, we can still try to reveal it
|
||||
await $this.electronService.showItemInFolder(resource.fsPath);
|
||||
await this.electronService.showItemInFolder(resolved.fsPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -428,6 +450,30 @@ export class ElectronWindow extends Disposable {
|
||||
return false; // not handled by us
|
||||
}
|
||||
});
|
||||
|
||||
this.openerService.registerExternalUriResolver({
|
||||
resolveExternalUri: async (uri: URI, options?: OpenOptions) => {
|
||||
if (options && options.allowTunneling) {
|
||||
const portMappingRequest = extractLocalHostUriMetaDataForPortMapping(uri);
|
||||
if (portMappingRequest) {
|
||||
const tunnel = await this.tunnelService.openTunnel(portMappingRequest.port);
|
||||
if (tunnel) {
|
||||
return {
|
||||
resolved: uri.with({ authority: `127.0.0.1:${tunnel.tunnelLocalPort}` }),
|
||||
dispose: () => tunnel.dispose(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private shouldOpenExternal(resource: URI, options?: OpenOptions) {
|
||||
const scheme = resource.scheme.toLowerCase();
|
||||
const preferOpenExternal = (scheme === Schemas.mailto || scheme === Schemas.http || scheme === Schemas.https);
|
||||
return (options && options.openExternal) || preferOpenExternal;
|
||||
}
|
||||
|
||||
private updateTouchbarMenu(): void {
|
||||
@@ -492,7 +538,7 @@ export class ElectronWindow extends Disposable {
|
||||
// Only update if the actions have changed
|
||||
if (!equals(this.lastInstalledTouchedBar, items)) {
|
||||
this.lastInstalledTouchedBar = items;
|
||||
this.windowService.updateTouchBar(items);
|
||||
this.electronService.updateTouchBar(items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +566,7 @@ export class ElectronWindow extends Disposable {
|
||||
crashReporter.start(deepClone(options));
|
||||
|
||||
// start crash reporter in the main process
|
||||
return this.windowsService.startCrashReporter(options);
|
||||
return this.electronService.startCrashReporter(options);
|
||||
}
|
||||
|
||||
private onAddFoldersRequest(request: IAddFoldersRequest): void {
|
||||
|
||||
Reference in New Issue
Block a user