Skip to content

Commit 7d10b5a

Browse files
author
Benjamin Pasero
committed
notifications - progress prevents close (microsoft#90274)
1 parent 5f7ec94 commit 7d10b5a

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/vs/workbench/browser/parts/notifications/notificationsCenter.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { INotificationsModel, INotificationChangeEvent, NotificationChangeType }
1111
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
1212
import { Emitter } from 'vs/base/common/event';
1313
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
14-
import { NotificationsCenterVisibleContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
14+
import { NotificationsCenterVisibleContext, INotificationsCenterController } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
1515
import { NotificationsList } from 'vs/workbench/browser/parts/notifications/notificationsList';
1616
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1717
import { addClass, removeClass, isAncestor, Dimension } from 'vs/base/browser/dom';
@@ -24,7 +24,7 @@ import { IAction } from 'vs/base/common/actions';
2424
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2525
import { assertAllDefined, assertIsDefined } from 'vs/base/common/types';
2626

27-
export class NotificationsCenter extends Themable {
27+
export class NotificationsCenter extends Themable implements INotificationsCenterController {
2828

2929
private static readonly MAX_DIMENSIONS = new Dimension(450, 400);
3030

@@ -284,8 +284,10 @@ export class NotificationsCenter extends Themable {
284284
this.hide();
285285

286286
// Close all
287-
while (this.model.notifications.length) {
288-
this.model.notifications[0].close();
287+
for (const notification of this.model.notifications) {
288+
if (!notification.hasProgress) {
289+
notification.close();
290+
}
289291
}
290292
}
291293
}

src/vs/workbench/browser/parts/notifications/notificationsCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl
107107
},
108108
handler: (accessor, args?: any) => {
109109
const notification = getNotificationFromContext(accessor.get(IListService), args);
110-
if (notification) {
110+
if (notification && !notification.hasProgress) {
111111
notification.close();
112112
}
113113
}

src/vs/workbench/browser/parts/notifications/notificationsToasts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Themable, NOTIFICATIONS_TOAST_BORDER, NOTIFICATIONS_BACKGROUND } from '
1515
import { IThemeService } from 'vs/platform/theme/common/themeService';
1616
import { widgetShadow } from 'vs/platform/theme/common/colorRegistry';
1717
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
18-
import { NotificationsToastsVisibleContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
18+
import { NotificationsToastsVisibleContext, INotificationsToastController } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
1919
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
2020
import { localize } from 'vs/nls';
2121
import { Severity, NotificationsFilter } from 'vs/platform/notification/common/notification';
@@ -39,7 +39,7 @@ enum ToastVisibility {
3939
VISIBLE
4040
}
4141

42-
export class NotificationsToasts extends Themable {
42+
export class NotificationsToasts extends Themable implements INotificationsToastController {
4343

4444
private static readonly MAX_WIDTH = 450;
4545
private static readonly MAX_NOTIFICATIONS = 3;

src/vs/workbench/browser/parts/notifications/notificationsViewer.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class NotificationTemplateRenderer extends Disposable {
306306
// Container
307307
toggleClass(this.template.container, 'expanded', notification.expanded);
308308
this.inputDisposables.add(addDisposableListener(this.template.container, EventType.MOUSE_UP, e => {
309-
if (e.button === 1 /* Middle Button */) {
309+
if (!notification.hasProgress && e.button === 1 /* Middle Button */) {
310310
EventHelper.stop(e);
311311

312312
notification.close();
@@ -403,8 +403,10 @@ export class NotificationTemplateRenderer extends Disposable {
403403
actions.push(notification.expanded ? NotificationTemplateRenderer.collapseNotificationAction : NotificationTemplateRenderer.expandNotificationAction);
404404
}
405405

406-
// Close
407-
actions.push(NotificationTemplateRenderer.closeNotificationAction);
406+
// Close (unless progress is showing)
407+
if (!notification.hasProgress) {
408+
actions.push(NotificationTemplateRenderer.closeNotificationAction);
409+
}
408410

409411
this.template.toolbar.clear();
410412
this.template.toolbar.context = notification;

0 commit comments

Comments
 (0)