From d5dda6fe4973be92999adae6a1a7c235fe7a9744 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 27 Jan 2022 07:28:46 -0800 Subject: [PATCH] Ensure quick pick is closed on view output Fixes #141615 --- .../terminal/browser/terminalInstance.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index bb54b7c3dd142..8f694a0f5bc48 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -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, @@ -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(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( @@ -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 {