提交 fc7727b0 编写于 作者: B Benjamin Pasero

debt - move out reload/quit to lifecycle service

上级 a3d77034
......@@ -19,6 +19,8 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { timeout } from 'vs/base/common/async';
import { IDriver, IElement, IWindowDriver } from 'vs/platform/driver/common/driver';
import { NativeImage } from 'electron';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IElectronMainService } from 'vs/platform/electron/electron-main/electronMainService';
function isSilentKeyCode(keyCode: KeyCode) {
return keyCode < KeyCode.KEY_0;
......@@ -35,7 +37,9 @@ export class Driver implements IDriver, IWindowDriverRegistry {
constructor(
private windowServer: IPCServer,
private options: IDriverOptions,
@IWindowsMainService private readonly windowsMainService: IWindowsMainService
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IElectronMainService private readonly electronMainService: IElectronMainService
) { }
async registerWindowDriver(windowId: number): Promise<IDriverOptions> {
......@@ -75,11 +79,11 @@ export class Driver implements IDriver, IWindowDriverRegistry {
throw new Error('Invalid window');
}
this.reloadingWindowIds.add(windowId);
this.windowsMainService.reload(window);
this.lifecycleMainService.reload(window);
}
async exitApplication(): Promise<void> {
return this.windowsMainService.quit();
return this.electronMainService.quit(undefined);
}
async dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
import { MessageBoxOptions, shell, OpenDevToolsOptions, SaveDialogOptions, OpenDialogOptions, CrashReporterStartOptions, crashReporter, Menu, BrowserWindow, app } from 'electron';
import { INativeOpenWindowOptions } from 'vs/platform/windows/node/window';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
......@@ -21,7 +21,7 @@ import { URI } from 'vs/base/common/uri';
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export interface IElectronMainService extends AddFirstParameterToFunctions<IElectronService, Promise<any> /* only methods, not events */, number /* window ID */> { }
export interface IElectronMainService extends AddFirstParameterToFunctions<IElectronService, Promise<any> /* only methods, not events */, number | undefined /* window ID */> { }
export const IElectronMainService = createDecorator<IElectronService>('electronMainService');
......@@ -67,11 +67,11 @@ export class ElectronMainService implements IElectronMainService {
}));
}
async getWindowCount(windowId: number): Promise<number> {
async getWindowCount(windowId: number | undefined): Promise<number> {
return this.windowsMainService.getWindowCount();
}
async getActiveWindowId(windowId: number): Promise<number | undefined> {
async getActiveWindowId(windowId: number | undefined): Promise<number | undefined> {
const activeWindow = BrowserWindow.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
if (activeWindow) {
return activeWindow.id;
......@@ -80,9 +80,9 @@ export class ElectronMainService implements IElectronMainService {
return undefined;
}
openWindow(windowId: number, options?: IOpenEmptyWindowOptions): Promise<void>;
openWindow(windowId: number, toOpen: IWindowOpenable[], options?: INativeOpenWindowOptions): Promise<void>;
openWindow(windowId: number, arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: INativeOpenWindowOptions): Promise<void> {
openWindow(windowId: number | undefined, options?: IOpenEmptyWindowOptions): Promise<void>;
openWindow(windowId: number | undefined, toOpen: IWindowOpenable[], options?: INativeOpenWindowOptions): Promise<void>;
openWindow(windowId: number | undefined, arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: INativeOpenWindowOptions): Promise<void> {
if (Array.isArray(arg1)) {
return this.doOpenWindow(windowId, arg1, arg2);
}
......@@ -90,7 +90,7 @@ export class ElectronMainService implements IElectronMainService {
return this.doOpenEmptyWindow(windowId, arg1);
}
private async doOpenWindow(windowId: number, toOpen: IWindowOpenable[], options: INativeOpenWindowOptions = Object.create(null)): Promise<void> {
private async doOpenWindow(windowId: number | undefined, toOpen: IWindowOpenable[], options: INativeOpenWindowOptions = Object.create(null)): Promise<void> {
if (toOpen.length > 0) {
this.windowsMainService.open({
context: OpenContext.API,
......@@ -108,26 +108,26 @@ export class ElectronMainService implements IElectronMainService {
}
}
private async doOpenEmptyWindow(windowId: number, options?: IOpenEmptyWindowOptions): Promise<void> {
private async doOpenEmptyWindow(windowId: number | undefined, options?: IOpenEmptyWindowOptions): Promise<void> {
this.windowsMainService.openEmptyWindow(OpenContext.API, options);
}
async toggleFullScreen(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async toggleFullScreen(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.toggleFullScreen();
}
}
async handleTitleDoubleClick(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async handleTitleDoubleClick(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.handleTitleDoubleClick();
}
}
async isMaximized(windowId: number): Promise<boolean> {
const window = this.windowsMainService.getWindowById(windowId);
async isMaximized(windowId: number | undefined): Promise<boolean> {
const window = this.windowById(windowId);
if (window) {
return window.win.isMaximized();
}
......@@ -135,29 +135,29 @@ export class ElectronMainService implements IElectronMainService {
return false;
}
async maximizeWindow(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async maximizeWindow(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.win.maximize();
}
}
async unmaximizeWindow(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async unmaximizeWindow(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.win.unmaximize();
}
}
async minimizeWindow(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async minimizeWindow(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.win.minimize();
}
}
async isWindowFocused(windowId: number): Promise<boolean> {
const window = this.windowsMainService.getWindowById(windowId);
async isWindowFocused(windowId: number | undefined): Promise<boolean> {
const window = this.windowById(windowId);
if (window) {
return window.win.isFocused();
}
......@@ -165,12 +165,12 @@ export class ElectronMainService implements IElectronMainService {
return false;
}
async focusWindow(windowId: number, options?: { windowId?: number; }): Promise<void> {
async focusWindow(windowId: number | undefined, options?: { windowId?: number; }): Promise<void> {
if (options && typeof options.windowId === 'number') {
windowId = options.windowId;
}
const window = this.windowsMainService.getWindowById(windowId);
const window = this.windowById(windowId);
if (window) {
if (isMacintosh) {
window.win.show();
......@@ -184,20 +184,20 @@ export class ElectronMainService implements IElectronMainService {
//#region Dialog
async showMessageBox(windowId: number, options: MessageBoxOptions): Promise<MessageBoxReturnValue> {
async showMessageBox(windowId: number | undefined, options: MessageBoxOptions): Promise<MessageBoxReturnValue> {
return this.dialogMainService.showMessageBox(options, this.toBrowserWindow(windowId));
}
async showSaveDialog(windowId: number, options: SaveDialogOptions): Promise<SaveDialogReturnValue> {
async showSaveDialog(windowId: number | undefined, options: SaveDialogOptions): Promise<SaveDialogReturnValue> {
return this.dialogMainService.showSaveDialog(options, this.toBrowserWindow(windowId));
}
async showOpenDialog(windowId: number, options: OpenDialogOptions): Promise<OpenDialogReturnValue> {
async showOpenDialog(windowId: number | undefined, options: OpenDialogOptions): Promise<OpenDialogReturnValue> {
return this.dialogMainService.showOpenDialog(options, this.toBrowserWindow(windowId));
}
private toBrowserWindow(windowId: number): BrowserWindow | undefined {
const window = this.windowsMainService.getWindowById(windowId);
private toBrowserWindow(windowId: number | undefined): BrowserWindow | undefined {
const window = this.windowById(windowId);
if (window) {
return window.win;
}
......@@ -205,7 +205,7 @@ export class ElectronMainService implements IElectronMainService {
return undefined;
}
async pickFileFolderAndOpen(windowId: number, options: INativeOpenDialogOptions): Promise<void> {
async pickFileFolderAndOpen(windowId: number | undefined, options: INativeOpenDialogOptions): Promise<void> {
const paths = await this.dialogMainService.pickFileFolder(options);
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFileFolder', options.telemetryExtraData);
......@@ -213,7 +213,7 @@ export class ElectronMainService implements IElectronMainService {
}
}
async pickFolderAndOpen(windowId: number, options: INativeOpenDialogOptions): Promise<void> {
async pickFolderAndOpen(windowId: number | undefined, options: INativeOpenDialogOptions): Promise<void> {
const paths = await this.dialogMainService.pickFolder(options);
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFolder', options.telemetryExtraData);
......@@ -221,7 +221,7 @@ export class ElectronMainService implements IElectronMainService {
}
}
async pickFileAndOpen(windowId: number, options: INativeOpenDialogOptions): Promise<void> {
async pickFileAndOpen(windowId: number | undefined, options: INativeOpenDialogOptions): Promise<void> {
const paths = await this.dialogMainService.pickFile(options);
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFile', options.telemetryExtraData);
......@@ -229,7 +229,7 @@ export class ElectronMainService implements IElectronMainService {
}
}
async pickWorkspaceAndOpen(windowId: number, options: INativeOpenDialogOptions): Promise<void> {
async pickWorkspaceAndOpen(windowId: number | undefined, options: INativeOpenDialogOptions): Promise<void> {
const paths = await this.dialogMainService.pickWorkspace(options);
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openWorkspace', options.telemetryExtraData);
......@@ -237,7 +237,7 @@ export class ElectronMainService implements IElectronMainService {
}
}
private doOpenPicked(openable: IWindowOpenable[], options: INativeOpenDialogOptions, windowId: number): void {
private doOpenPicked(openable: IWindowOpenable[], options: INativeOpenDialogOptions, windowId: number | undefined): void {
this.windowsMainService.open({
context: OpenContext.DIALOG,
contextWindowId: windowId,
......@@ -263,32 +263,32 @@ export class ElectronMainService implements IElectronMainService {
//#region OS
async showItemInFolder(windowId: number, path: string): Promise<void> {
async showItemInFolder(windowId: number | undefined, path: string): Promise<void> {
shell.showItemInFolder(path);
}
async setRepresentedFilename(windowId: number, path: string): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async setRepresentedFilename(windowId: number | undefined, path: string): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.setRepresentedFilename(path);
}
}
async setDocumentEdited(windowId: number, edited: boolean): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async setDocumentEdited(windowId: number | undefined, edited: boolean): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.win.setDocumentEdited(edited);
}
}
async openExternal(windowId: number, url: string): Promise<boolean> {
async openExternal(windowId: number | undefined, url: string): Promise<boolean> {
shell.openExternal(url);
return true;
}
async updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async updateTouchBar(windowId: number | undefined, items: ISerializableCommandAction[][]): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.updateTouchBar(items);
}
......@@ -326,35 +326,48 @@ export class ElectronMainService implements IElectronMainService {
//#region Lifecycle
async relaunch(windowId: number, options?: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
async relaunch(windowId: number | undefined, options?: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
return this.lifecycleMainService.relaunch(options);
}
async reload(windowId: number, options?: { disableExtensions?: boolean }): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async reload(windowId: number | undefined, options?: { disableExtensions?: boolean }): Promise<void> {
const window = this.windowById(windowId);
if (window) {
return this.windowsMainService.reload(window, options && options.disableExtensions ? { _: [], 'disable-extensions': true } : undefined);
return this.lifecycleMainService.reload(window, options && options.disableExtensions ? { _: [], 'disable-extensions': true } : undefined);
}
}
async closeWindow(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async closeWindow(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
return window.win.close();
}
}
async quit(windowId: number): Promise<void> {
return this.windowsMainService.quit();
async quit(windowId: number | undefined): Promise<void> {
// If the user selected to exit from an extension development host window, do not quit, but just
// close the window unless this is the last window that is opened.
const window = this.windowsMainService.getLastActiveWindow();
if (window && window.isExtensionDevelopmentHost && this.windowsMainService.getWindowCount() > 1) {
window.win.close();
}
// Otherwise: normal quit
else {
setTimeout(() => {
this.lifecycleMainService.quit();
}, 10 /* delay to unwind callback stack (IPC) */);
}
}
//#endregion
//#region Connectivity
async resolveProxy(windowId: number, url: string): Promise<string | undefined> {
async resolveProxy(windowId: number | undefined, url: string): Promise<string | undefined> {
return new Promise(resolve => {
const window = this.windowsMainService.getWindowById(windowId);
const window = this.windowById(windowId);
if (window && window.win && window.win.webContents && window.win.webContents.session) {
window.win.webContents.session.resolveProxy(url, proxy => resolve(proxy));
} else {
......@@ -367,15 +380,15 @@ export class ElectronMainService implements IElectronMainService {
//#region Development
async openDevTools(windowId: number, options?: OpenDevToolsOptions): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async openDevTools(windowId: number | undefined, options?: OpenDevToolsOptions): Promise<void> {
const window = this.windowById(windowId);
if (window) {
window.win.webContents.openDevTools(options);
}
}
async toggleDevTools(windowId: number): Promise<void> {
const window = this.windowsMainService.getWindowById(windowId);
async toggleDevTools(windowId: number | undefined): Promise<void> {
const window = this.windowById(windowId);
if (window) {
const contents = window.win.webContents;
if (isMacintosh && window.hasHiddenTitleBarStyle() && !window.isFullScreen() && !contents.isDevToolsOpened()) {
......@@ -386,7 +399,7 @@ export class ElectronMainService implements IElectronMainService {
}
}
async startCrashReporter(windowId: number, options: CrashReporterStartOptions): Promise<void> {
async startCrashReporter(windowId: number | undefined, options: CrashReporterStartOptions): Promise<void> {
crashReporter.start(options);
}
......@@ -396,7 +409,7 @@ export class ElectronMainService implements IElectronMainService {
// TODO@Isidor move into debug IPC channel (https://github.com/microsoft/vscode/issues/81060)
async openExtensionDevelopmentHostWindow(windowId: number, args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
async openExtensionDevelopmentHostWindow(windowId: number | undefined, args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
const extDevPaths = args.extensionDevelopmentPath;
if (extDevPaths) {
this.windowsMainService.openExtensionDevelopmentHostWindow(extDevPaths, {
......@@ -408,4 +421,12 @@ export class ElectronMainService implements IElectronMainService {
}
//#endregion
private windowById(windowId: number | undefined): ICodeWindow | undefined {
if (typeof windowId !== 'number') {
return undefined;
}
return this.windowsMainService.getWindowById(windowId);
}
}
......@@ -13,6 +13,7 @@ import { handleVetos } from 'vs/platform/lifecycle/common/lifecycle';
import { isMacintosh, isWindows } from 'vs/base/common/platform';
import { Disposable } from 'vs/base/common/lifecycle';
import { Barrier } from 'vs/base/common/async';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
export const ILifecycleMainService = createDecorator<ILifecycleMainService>('lifecycleMainService');
......@@ -82,6 +83,11 @@ export interface ILifecycleMainService {
*/
readonly onBeforeWindowUnload: Event<IWindowUnloadEvent>;
/**
* Reload a window. All lifecycle event handlers are triggered.
*/
reload(window: ICodeWindow, cli?: ParsedArgs): Promise<void>;
/**
* Unload a window for the provided reason. All lifecycle event handlers are triggered.
*/
......@@ -360,6 +366,15 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
});
}
async reload(window: ICodeWindow, cli?: ParsedArgs): Promise<void> {
// Only reload when the window has not vetoed this
const veto = await this.unload(window, UnloadReason.RELOAD);
if (!veto) {
window.reload(undefined, cli);
}
}
async unload(window: ICodeWindow, reason: UnloadReason): Promise<boolean /* veto */> {
// Always allow to unload a window that is not yet ready
......
......@@ -113,8 +113,8 @@ export class Menubar {
// File Menu Items
this.fallbackMenuHandlers['workbench.action.files.newUntitledFile'] = () => this.windowsMainService.openEmptyWindow(OpenContext.MENU);
this.fallbackMenuHandlers['workbench.action.newWindow'] = () => this.windowsMainService.openEmptyWindow(OpenContext.MENU);
this.fallbackMenuHandlers['workbench.action.files.openFileFolder'] = (menuItem, win, event) => this.electronMainService.pickFileFolderAndOpen(-1, { forceNewWindow: this.isOptionClick(event), telemetryExtraData: { from: telemetryFrom } });
this.fallbackMenuHandlers['workbench.action.openWorkspace'] = (menuItem, win, event) => this.electronMainService.pickWorkspaceAndOpen(-1, { forceNewWindow: this.isOptionClick(event), telemetryExtraData: { from: telemetryFrom } });
this.fallbackMenuHandlers['workbench.action.files.openFileFolder'] = (menuItem, win, event) => this.electronMainService.pickFileFolderAndOpen(undefined, { forceNewWindow: this.isOptionClick(event), telemetryExtraData: { from: telemetryFrom } });
this.fallbackMenuHandlers['workbench.action.openWorkspace'] = (menuItem, win, event) => this.electronMainService.pickWorkspaceAndOpen(undefined, { forceNewWindow: this.isOptionClick(event), telemetryExtraData: { from: telemetryFrom } });
// Recent Menu Items
this.fallbackMenuHandlers['workbench.action.clearRecentFiles'] = () => this.workspacesHistoryMainService.clearRecentlyOpened();
......@@ -370,7 +370,7 @@ export class Menubar {
!!BrowserWindow.getFocusedWindow() || // allow to quit when window has focus (fix for https://github.com/Microsoft/vscode/issues/39191)
this.windowsMainService.getLastActiveWindow()!.isMinimized() // allow to quit when window has no focus but is minimized (https://github.com/Microsoft/vscode/issues/63000)
) {
this.windowsMainService.quit();
this.electronMainService.quit(undefined);
}
}
}));
......
......@@ -103,8 +103,6 @@ export interface IWindowsMainService {
openEmptyWindow(context: OpenContext, options?: IOpenEmptyWindowOptions): ICodeWindow[];
openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): ICodeWindow[];
reload(win: ICodeWindow, cli?: ParsedArgs): void;
sendToFocused(channel: string, ...args: any[]): void;
sendToAll(channel: string, payload: any, windowIdsToIgnore?: number[]): void;
......@@ -113,8 +111,6 @@ export interface IWindowsMainService {
getWindowById(windowId: number): ICodeWindow | undefined;
getWindows(): ICodeWindow[];
getWindowCount(): number;
quit(): void;
}
export interface IOpenConfiguration {
......
......@@ -369,6 +369,19 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
};
}
openEmptyWindow(context: OpenContext, options?: IOpenEmptyWindowOptions): ICodeWindow[] {
let cli = this.environmentService.args;
const remote = options && options.remoteAuthority;
if (cli && (cli.remote !== remote)) {
cli = { ...cli, remote };
}
const forceReuseWindow = options && options.forceReuseWindow;
const forceNewWindow = !forceReuseWindow;
return this.open({ context, cli, forceEmpty: true, forceNewWindow, forceReuseWindow });
}
open(openConfig: IOpenConfiguration): ICodeWindow[] {
this.logService.trace('windowsManager#open');
openConfig = this.validateOpenConfig(openConfig);
......@@ -1218,7 +1231,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
// on the same extension path.
const existingWindow = findWindowOnExtensionDevelopmentPath(WindowsMainService.WINDOWS, extensionDevelopmentPath);
if (existingWindow) {
this.reload(existingWindow, openConfig.cli);
this.lifecycleMainService.reload(existingWindow, openConfig.cli);
existingWindow.focus(); // make sure it gets focus and is restored
return [existingWindow];
......@@ -1399,7 +1412,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
once(window.onClose)(() => this.onWindowClosed(window!));
once(window.onDestroy)(() => this.onBeforeWindowClose(window!)); // try to save state before destroy because close will not fire
window.win.webContents.removeAllListeners('devtools-reload-page'); // remove built in listener so we can handle this on our own
window.win.webContents.on('devtools-reload-page', () => this.reload(window!));
window.win.webContents.on('devtools-reload-page', () => this.lifecycleMainService.reload(window!));
// Lifecycle
(this.lifecycleMainService as LifecycleMainService).registerWindow(window);
......@@ -1586,15 +1599,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
return state;
}
async reload(win: ICodeWindow, cli?: ParsedArgs): Promise<void> {
// Only reload when the window has not vetoed this
const veto = await this.lifecycleMainService.unload(win, UnloadReason.RELOAD);
if (!veto) {
win.reload(undefined, cli);
}
}
focusLastActive(cli: ParsedArgs, context: OpenContext): ICodeWindow {
const lastActive = this.getLastActiveWindow();
if (lastActive) {
......@@ -1615,19 +1619,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
return getLastActiveWindow(WindowsMainService.WINDOWS.filter(window => window.remoteAuthority === remoteAuthority));
}
openEmptyWindow(context: OpenContext, options?: IOpenEmptyWindowOptions): ICodeWindow[] {
let cli = this.environmentService.args;
const remote = options && options.remoteAuthority;
if (cli && (cli.remote !== remote)) {
cli = { ...cli, remote };
}
const forceReuseWindow = options && options.forceReuseWindow;
const forceNewWindow = !forceReuseWindow;
return this.open({ context, cli, forceEmpty: true, forceNewWindow, forceReuseWindow });
}
sendToFocused(channel: string, ...args: any[]): void {
const focusedWindow = this.getFocusedWindow() || this.getLastActiveWindow();
......@@ -1657,6 +1648,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
getWindowById(windowId: number): ICodeWindow | undefined {
const res = WindowsMainService.WINDOWS.filter(window => window.id === windowId);
return arrays.firstOrDefault(res);
}
......@@ -1678,21 +1670,4 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
this._onWindowsCountChanged.fire({ oldCount: WindowsMainService.WINDOWS.length + 1, newCount: WindowsMainService.WINDOWS.length });
this._onWindowClose.fire(win.id);
}
quit(): void {
// If the user selected to exit from an extension development host window, do not quit, but just
// close the window unless this is the last window that is opened.
const window = this.getFocusedWindow();
if (window && window.isExtensionDevelopmentHost && this.getWindowCount() > 1) {
window.win.close();
}
// Otherwise: normal quit
else {
setTimeout(() => {
this.lifecycleMainService.quit();
}, 10 /* delay to unwind callback stack (IPC) */);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册