env - only show one notifications not two (fix #111246)

This commit is contained in:
Benjamin Pasero
2020-11-25 11:38:20 +01:00
parent ce6f5e0f8f
commit 7bbf45c14e
7 changed files with 30 additions and 17 deletions
+5 -2
View File
@@ -87,6 +87,7 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { DisplayMainService, IDisplayMainService } from 'vs/platform/display/electron-main/displayMainService';
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
import { isEqualOrParent } from 'vs/base/common/extpath';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
export class CodeApplication extends Disposable {
private windowsMainService: IWindowsMainService | undefined;
@@ -290,9 +291,11 @@ export class CodeApplication extends Disposable {
// Handle slow shell environment resolve calls:
// - a warning after 3s but continue to resolve
// - an error after 10s and stop trying to resolve
const shellEnvSlowWarningHandle = setTimeout(() => window?.sendWhenReady('vscode:showShellEnvSlowWarning'), 3000);
const cts = new CancellationTokenSource();
const shellEnvSlowWarningHandle = setTimeout(() => window?.sendWhenReady('vscode:showShellEnvSlowWarning', cts.token), 3000);
const shellEnvTimeoutErrorHandle = setTimeout(function () {
window?.sendWhenReady('vscode:showShellEnvTimeoutError');
cts.dispose(true);
window?.sendWhenReady('vscode:showShellEnvTimeoutError', CancellationToken.None);
acceptShellEnv({});
}, 10000);
+2 -1
View File
@@ -13,6 +13,7 @@ import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeH
import { IEncryptionMainService } from 'vs/platform/encryption/electron-main/encryptionMainService';
import { generateUuid } from 'vs/base/common/uuid';
import product from 'vs/platform/product/common/product';
import { CancellationToken } from 'vs/base/common/cancellation';
interface ElectronAuthenticationResponseDetails extends AuthenticationResponseDetails {
firstAuthAttempt?: boolean; // https://github.com/electron/electron/blob/84a42a050e7d45225e69df5bd2d2bf9f1037ea41/shell/browser/login_handler.cc#L70
@@ -192,7 +193,7 @@ export class ProxyAuthHandler2 extends Disposable {
password: this.sessionCredentials?.password ?? storedPassword, // prefer to show already used password (if any) over stored
replyChannel: `vscode:proxyAuthResponse:${generateUuid()}`
};
window.sendWhenReady('vscode:openProxyAuthenticationDialog', payload);
window.sendWhenReady('vscode:openProxyAuthenticationDialog', CancellationToken.None, payload);
this.state = ProxyAuthState.LoginDialogShown;
// Handle reply
+11 -6
View File
@@ -36,6 +36,7 @@ import { IStorageMainService } from 'vs/platform/storage/node/storageMainService
import { ByteSize, IFileService } from 'vs/platform/files/common/files';
import { FileAccess, Schemas } from 'vs/base/common/network';
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
import { CancellationToken } from 'vs/base/common/cancellation';
export interface IWindowCreationOptions {
state: IWindowState;
@@ -518,11 +519,11 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Window Fullscreen
this._win.on('enter-full-screen', () => {
this.sendWhenReady('vscode:enterFullScreen');
this.sendWhenReady('vscode:enterFullScreen', CancellationToken.None);
});
this._win.on('leave-full-screen', () => {
this.sendWhenReady('vscode:leaveFullScreen');
this.sendWhenReady('vscode:leaveFullScreen', CancellationToken.None);
});
// Window Failed to load
@@ -1100,7 +1101,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
// Events
this.sendWhenReady(fullscreen ? 'vscode:enterFullScreen' : 'vscode:leaveFullScreen');
this.sendWhenReady(fullscreen ? 'vscode:enterFullScreen' : 'vscode:leaveFullScreen', CancellationToken.None);
// Respect configured menu bar visibility or default to toggle if not set
if (this.currentMenuBarVisibility) {
@@ -1241,11 +1242,15 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
sendWhenReady(channel: string, ...args: any[]): void {
sendWhenReady(channel: string, token: CancellationToken, ...args: any[]): void {
if (this.isReady) {
this.send(channel, ...args);
} else {
this.ready().then(() => this.send(channel, ...args));
this.ready().then(() => {
if (!token.isCancellationRequested) {
this.send(channel, ...args);
}
});
}
}
@@ -1295,7 +1300,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
mode: 'buttons',
segmentStyle: 'automatic',
change: (selectedIndex) => {
this.sendWhenReady('vscode:runAction', { id: (control.segments[selectedIndex] as ITouchBarSegment).id, from: 'touchbar' });
this.sendWhenReady('vscode:runAction', CancellationToken.None, { id: (control.segments[selectedIndex] as ITouchBarSegment).id, from: 'touchbar' });
}
});
@@ -20,6 +20,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { IDiagnosticInfoOptions, IDiagnosticInfo, IRemoteDiagnosticInfo, IRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { IMainProcessInfo, IWindowInfo } from 'vs/platform/launch/node/launch';
import { isLaunchedFromCli } from 'vs/platform/environment/node/argvHelper';
import { CancellationToken } from 'vs/base/common/cancellation';
export const ID = 'launchMainService';
export const ILaunchMainService = createDecorator<ILaunchMainService>(ID);
@@ -248,7 +249,7 @@ export class LaunchMainService implements ILaunchMainService {
folders: options.includeWorkspaceMetadata ? this.getFolderURIs(window) : undefined
};
window.sendWhenReady('vscode:getDiagnosticInfo', { replyChannel, args });
window.sendWhenReady('vscode:getDiagnosticInfo', CancellationToken.None, { replyChannel, args });
ipcMain.once(replyChannel, (_: IpcEvent, data: IRemoteDiagnosticInfo) => {
// No data is returned if getting the connection fails.
@@ -24,6 +24,7 @@ import { IStateService } from 'vs/platform/state/node/state';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
import { CancellationToken } from 'vs/base/common/cancellation';
const telemetryFrom = 'menu';
@@ -754,10 +755,10 @@ export class Menubar {
if (invocation.type === 'commandId') {
const runActionPayload: INativeRunActionInWindowRequest = { id: invocation.commandId, from: 'menu' };
activeWindow.sendWhenReady('vscode:runAction', runActionPayload);
activeWindow.sendWhenReady('vscode:runAction', CancellationToken.None, runActionPayload);
} else {
const runKeybindingPayload: INativeRunKeybindingInWindowRequest = { userSettingsLabel: invocation.userSettingsLabel };
activeWindow.sendWhenReady('vscode:runKeybinding', runKeybindingPayload);
activeWindow.sendWhenReady('vscode:runKeybinding', CancellationToken.None, runKeybindingPayload);
}
} else {
this.logService.trace('menubar#runActionInRenderer: no active window found', invocation);
@@ -14,6 +14,7 @@ import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import { URI } from 'vs/base/common/uri';
import { Rectangle, BrowserWindow, WebContents } from 'electron';
import { IDisposable } from 'vs/base/common/lifecycle';
import { CancellationToken } from 'vs/base/common/cancellation';
export interface IWindowState {
width?: number;
@@ -72,7 +73,7 @@ export interface ICodeWindow extends IDisposable {
getBounds(): Rectangle;
send(channel: string, ...args: any[]): void;
sendWhenReady(channel: string, ...args: any[]): void;
sendWhenReady(channel: string, token: CancellationToken, ...args: any[]): void;
readonly isFullScreen: boolean;
toggleFullScreen(): void;
@@ -39,6 +39,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
import { isWindowsDriveLetter, toSlashes, parseLineAndColumnAware } from 'vs/base/common/extpath';
import { CharCode } from 'vs/base/common/charCode';
import { getPathLabel } from 'vs/base/common/labels';
import { CancellationToken } from 'vs/base/common/cancellation';
export interface IWindowState {
workspace?: IWorkspaceIdentifier;
@@ -758,7 +759,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
params.termProgram = configuration.userEnv['TERM_PROGRAM'];
}
window.sendWhenReady('vscode:openFiles', params);
window.sendWhenReady('vscode:openFiles', CancellationToken.None, params);
return window;
}
@@ -767,7 +768,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
window.focus(); // make sure window has focus
const request: IAddFoldersRequest = { foldersToAdd };
window.sendWhenReady('vscode:addFolders', request);
window.sendWhenReady('vscode:addFolders', CancellationToken.None, request);
return window;
}
@@ -1679,7 +1680,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
const focusedWindow = this.getFocusedWindow() || this.getLastActiveWindow();
if (focusedWindow) {
focusedWindow.sendWhenReady(channel, ...args);
focusedWindow.sendWhenReady(channel, CancellationToken.None, ...args);
}
}
@@ -1689,7 +1690,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
continue; // do not send if we are instructed to ignore it
}
window.sendWhenReady(channel, payload);
window.sendWhenReady(channel, CancellationToken.None, payload);
}
}