Skip to content

Commit 9b0917d

Browse files
authored
Merge pull request microsoft#141650 from microsoft/tyriar/141615
Ensure quick pick is closed on view output
2 parents 3cc9dd4 + 4c83b11 commit 9b0917d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
784784
}
785785
}
786786
const outputProvider = this._instantiationService.createInstance(TerminalOutputProvider);
787-
const result = await this._quickInputService.pick(items.reverse(), {
788-
onDidTriggerItemButton: (async e => {
789-
const selectedCommand = e.item.command;
787+
const quickPick = this._quickInputService.createQuickPick();
788+
quickPick.items = items.reverse();
789+
return new Promise<void>(r => {
790+
quickPick.onDidTriggerItemButton(async e => {
791+
const selectedCommand = (e.item as Item).command;
790792
const output = selectedCommand?.getOutput();
791793
if (output && selectedCommand?.command) {
792794
const textContent = await outputProvider.provideTextContent(URI.from(
@@ -797,16 +799,21 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
797799
query: `terminal-output-${selectedCommand.timestamp}-${this.instanceId}`
798800
}));
799801
if (textContent) {
800-
this._editorService.openEditor({
802+
await this._editorService.openEditor({
801803
resource: textContent.uri
802804
});
803805
}
804806
}
805-
})
807+
quickPick.hide();
808+
});
809+
quickPick.onDidAccept(e => {
810+
const result = quickPick.activeItems[0];
811+
this.sendText(type === 'cwd' ? `cd ${result.label}` : result.label, true);
812+
quickPick.hide();
813+
});
814+
quickPick.show();
815+
quickPick.onDidHide(() => r());
806816
});
807-
if (result) {
808-
this.sendText(type === 'cwd' ? `cd ${result.label}` : result.label, true);
809-
}
810817
}
811818

812819
detachFromElement(): void {

0 commit comments

Comments
 (0)