提交 690d0e33 编写于 作者: B Benjamin Pasero

window - cleanup reload() method

上级 1568c0ca
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import * as os from 'os'; import * as os from 'os';
import * as path from 'vs/base/common/path'; import * as path from 'vs/base/common/path';
import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import * as perf from 'vs/base/common/performance'; import * as perf from 'vs/base/common/performance';
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
...@@ -111,8 +110,6 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -111,8 +110,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[]; private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[];
private pendingLoadConfig?: INativeWindowConfiguration;
private marketplaceHeadersPromise: Promise<object>; private marketplaceHeadersPromise: Promise<object>;
private readonly touchBarGroups: TouchBarSegmentedControl[]; private readonly touchBarGroups: TouchBarSegmentedControl[];
...@@ -286,6 +283,8 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -286,6 +283,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this.registerListeners(); this.registerListeners();
} }
private pendingLoadConfig: INativeWindowConfiguration | undefined;
private currentConfig: INativeWindowConfiguration | undefined; private currentConfig: INativeWindowConfiguration | undefined;
get config(): INativeWindowConfiguration | undefined { return this.currentConfig; } get config(): INativeWindowConfiguration | undefined { return this.currentConfig; }
...@@ -297,11 +296,11 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -297,11 +296,11 @@ export class CodeWindow extends Disposable implements ICodeWindow {
get hasHiddenTitleBarStyle(): boolean { return !!this.hiddenTitleBarStyle; } get hasHiddenTitleBarStyle(): boolean { return !!this.hiddenTitleBarStyle; }
get isExtensionDevelopmentHost(): boolean { return !!(this.config && this.config.extensionDevelopmentPath); } get isExtensionDevelopmentHost(): boolean { return !!(this.currentConfig?.extensionDevelopmentPath); }
get isExtensionTestHost(): boolean { return !!(this.config && this.config.extensionTestsPath); } get isExtensionTestHost(): boolean { return !!(this.currentConfig?.extensionTestsPath); }
get isExtensionDevelopmentTestFromCli(): boolean { return this.isExtensionDevelopmentHost && this.isExtensionTestHost && !this.config?.debugId; } get isExtensionDevelopmentTestFromCli(): boolean { return this.isExtensionDevelopmentHost && this.isExtensionTestHost && !this.currentConfig?.debugId; }
setRepresentedFilename(filename: string): void { setRepresentedFilename(filename: string): void {
if (isMacintosh) { if (isMacintosh) {
...@@ -739,10 +738,10 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -739,10 +738,10 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._onLoad.fire(); this._onLoad.fire();
} }
reload(configurationIn?: INativeWindowConfiguration, cli?: NativeParsedArgs): void { reload(cli?: NativeParsedArgs): void {
// If config is not provided, copy our current one // Copy our current config for reuse
const configuration = configurationIn ? configurationIn : objects.mixin({}, this.currentConfig); const configuration = Object.assign({}, this.currentConfig);
// Delete some properties we do not want during reload // Delete some properties we do not want during reload
delete configuration.filesToOpenOrCreate; delete configuration.filesToOpenOrCreate;
...@@ -820,10 +819,9 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -820,10 +819,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// large depending on user configuration, so we can only remove it in that case. // large depending on user configuration, so we can only remove it in that case.
let configUrl = this.doGetUrl(config); let configUrl = this.doGetUrl(config);
if (configUrl.length > CodeWindow.MAX_URL_LENGTH) { if (configUrl.length > CodeWindow.MAX_URL_LENGTH) {
delete config.userEnv;
this.logService.warn('Application URL exceeds maximum of 2MB and was shortened.'); this.logService.warn('Application URL exceeds maximum of 2MB and was shortened.');
configUrl = this.doGetUrl(config); configUrl = this.doGetUrl({ ...config, userEnv: undefined });
if (configUrl.length > CodeWindow.MAX_URL_LENGTH) { if (configUrl.length > CodeWindow.MAX_URL_LENGTH) {
this.logService.error('Application URL exceeds maximum of 2MB and cannot be loaded.'); this.logService.error('Application URL exceeds maximum of 2MB and cannot be loaded.');
...@@ -1139,7 +1137,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -1139,7 +1137,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
} }
private getMenuBarVisibility(): MenuBarVisibility { private getMenuBarVisibility(): MenuBarVisibility {
let menuBarVisibility = getMenuBarVisibility(this.configurationService, this.environmentService, !!this.config?.extensionDevelopmentPath); let menuBarVisibility = getMenuBarVisibility(this.configurationService, this.environmentService, !!this.currentConfig?.extensionDevelopmentPath);
if (['visible', 'toggle', 'hidden'].indexOf(menuBarVisibility) < 0) { if (['visible', 'toggle', 'hidden'].indexOf(menuBarVisibility) < 0) {
menuBarVisibility = 'default'; menuBarVisibility = 'default';
} }
......
...@@ -371,7 +371,7 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe ...@@ -371,7 +371,7 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
// Only reload when the window has not vetoed this // Only reload when the window has not vetoed this
const veto = await this.unload(window, UnloadReason.RELOAD); const veto = await this.unload(window, UnloadReason.RELOAD);
if (!veto) { if (!veto) {
window.reload(undefined, cli); window.reload(cli);
} }
} }
......
...@@ -59,7 +59,7 @@ export interface ICodeWindow extends IDisposable { ...@@ -59,7 +59,7 @@ export interface ICodeWindow extends IDisposable {
addTabbedWindow(window: ICodeWindow): void; addTabbedWindow(window: ICodeWindow): void;
load(config: INativeWindowConfiguration, isReload?: boolean): void; load(config: INativeWindowConfiguration, isReload?: boolean): void;
reload(configuration?: INativeWindowConfiguration, cli?: NativeParsedArgs): void; reload(cli?: NativeParsedArgs): void;
focus(options?: { force: boolean }): void; focus(options?: { force: boolean }): void;
close(): void; close(): void;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册