Skip to content

Commit

Permalink
Ensure quick pick is closed on view output
Browse files Browse the repository at this point in the history
Fixes #141615
  • Loading branch information
Tyriar committed Jan 27, 2022
1 parent 82dac48 commit d5dda6f
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const buttons: IQuickInputButton[] = [{
iconClass,
tooltip: nls.localize('viewCommandOutput', "View Command Output"),
alwaysVisible: true
alwaysVisible: true,
}];
items.push({
label,
Expand All @@ -784,9 +784,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
}
const outputProvider = this._instantiationService.createInstance(TerminalOutputProvider);
const result = await this._quickInputService.pick(items.reverse(), {
onDidTriggerItemButton: (async e => {
const selectedCommand = e.item.command;
const quickPick = this._quickInputService.createQuickPick();
quickPick.items = items.reverse();
return new Promise<void>(r => {
quickPick.onDidTriggerItemButton(async e => {
const selectedCommand = (e.item as Item).command;
const output = selectedCommand?.getOutput();
if (output && selectedCommand?.command) {
const textContent = await outputProvider.provideTextContent(URI.from(
Expand All @@ -802,11 +804,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
});
}
}
})
quickPick.hide();
});
quickPick.onDidAccept(e => {
const result = quickPick.activeItems[0];
this.sendText(type === 'cwd' ? `cd ${result.label}` : result.label, true);
quickPick.hide();
});
quickPick.show();
quickPick.onDidHide(() => r());
});
if (result) {
this.sendText(type === 'cwd' ? `cd ${result.label}` : result.label, true);
}
}

detachFromElement(): void {
Expand Down

0 comments on commit d5dda6f

Please sign in to comment.