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' });
}
});