Skip to content

Commit

Permalink
debug: only show the cancel if the progress event is cancelable
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Mar 18, 2020
1 parent 51ec5e9 commit 03ee6b2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/vs/workbench/contrib/debug/browser/debugViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export class DebugViewPaneContainer extends ViewPaneContainer {
progressListener = session.onDidProgressStart(async progressStartEvent => {
// Update title area to show the cancel progress action
this.progressEvents.push({ session: session, event: progressStartEvent });
this.cancelAction.tooltip = nls.localize('cancelProgress', "Cancel {0}", progressStartEvent.body.title);
this.updateTitleArea();
if (progressStartEvent.body.cancellable) {
this.cancelAction.tooltip = nls.localize('cancelProgress', "Cancel {0}", progressStartEvent.body.title);
this.updateTitleArea();
}
await this.progressService.withProgress({ location: VIEWLET_ID }, () => {
return new Promise(r => {
// Show progress until a progress end event comes or the session ends
Expand All @@ -103,9 +105,11 @@ export class DebugViewPaneContainer extends ViewPaneContainer {
});
});
});
this.cancelAction.tooltip = nls.localize('cancel', "Cancel");
this.progressEvents = this.progressEvents.filter(pe => pe.event.body.progressId !== progressStartEvent.body.progressId);
this.updateTitleArea();
if (progressStartEvent.body.cancellable) {
this.cancelAction.tooltip = nls.localize('cancel', "Cancel");
this.updateTitleArea();
}
});
}
}));
Expand Down Expand Up @@ -144,8 +148,10 @@ export class DebugViewPaneContainer extends ViewPaneContainer {
@memoize
private get cancelAction(): Action {
return this._register(new Action('debug.cancelProgress', nls.localize('cancel', "Cancel"), 'debug-action codicon codicon-stop', true, async () => {
let { event, session } = this.progressEvents[this.progressEvents.length - 1];
await session.cancel(event.body.progressId);
const progressEvent = this.progressEvents.filter(e => e.event.body.cancellable).pop();
if (progressEvent) {
await progressEvent.session.cancel(progressEvent.event.body.progressId);
}
}));
}

Expand Down Expand Up @@ -180,7 +186,7 @@ export class DebugViewPaneContainer extends ViewPaneContainer {
result = [this.startAction, this.configureAction, this.toggleReplAction];
}

if (this.progressEvents.length) {
if (this.progressEvents.filter(e => e.event.body.cancellable).length) {
result.unshift(this.cancelAction);
}

Expand Down

0 comments on commit 03ee6b2

Please sign in to comment.