diff --git a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts index 6132c599e14d96ee4926c8f6e86f338bb428494b..8d0974b77291c7d02bb0203a15537b475b04fb2e 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts @@ -210,16 +210,23 @@ export class NotificationsToasts extends Themable { disposables.push(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false)); // Install Timers - let timeoutHandle: any; + let purgeTimeoutHandle: any; + let pendingPurgeTimeoutHandle: any; const hideAfterTimeout = () => { - timeoutHandle = setTimeout(() => { + purgeTimeoutHandle = setTimeout(() => { if ( item.sticky || // never hide sticky notifications notificationList.hasFocus() || // never hide notifications with focus isMouseOverToast || // never hide notifications under mouse !this.windowHasFocus // never hide when window has no focus ) { - hideAfterTimeout(); + // If the notification should not be hidden yet for the reasons outlined + // above, we delay an additional check by at least PURGE_TIMEOUT so that + // if the condition changes to hide the notification, the timeout will + // be at least PURGE_TIMEOUT (+ the time it took to change the state) + pendingPurgeTimeoutHandle = setTimeout(() => { + hideAfterTimeout(); + }, NotificationsToasts.PURGE_TIMEOUT[item.severity]); } else { this.removeToast(item); } @@ -228,7 +235,8 @@ export class NotificationsToasts extends Themable { hideAfterTimeout(); - disposables.push(toDisposable(() => clearTimeout(timeoutHandle))); + disposables.push(toDisposable(() => clearTimeout(purgeTimeoutHandle))); + disposables.push(toDisposable(() => clearTimeout(pendingPurgeTimeoutHandle))); } private removeToast(item: INotificationViewItem): void {