From 5b3380c48ed513e320dccc8a981f1879ea6479df Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:08:43 -0700 Subject: [PATCH] Don't clear after timeout, highlight multi-line commands Fixes #208591 --- .../browser/terminalRunRecentQuickPick.ts | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick.ts b/src/vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick.ts index 8c8449114d3..c6f6bdb61d4 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick.ts @@ -259,21 +259,36 @@ export async function showRunRecentQuickPick( } }); let terminalScrollStateSaved = false; + function restoreScrollState() { + terminalScrollStateSaved = false; + instance.xterm?.markTracker.restoreScrollState(); + instance.xterm?.markTracker.clear(); + } quickPick.onDidChangeActive(async () => { const xterm = instance.xterm; if (!xterm) { return; } const [item] = quickPick.activeItems; - if ('command' in item && item.command) { + if ('command' in item && item.command && item.command.marker) { if (!terminalScrollStateSaved) { xterm.markTracker.saveScrollState(); terminalScrollStateSaved = true; } - xterm.markTracker.revealCommand(item.command); + const promptRowCount = item.command.getPromptRowCount(); + const commandRowCount = item.command.getCommandRowCount(); + xterm.markTracker.revealRange({ + start: { + x: 1, + y: item.command.marker.line - (promptRowCount - 1) + 1 + }, + end: { + x: instance.cols, + y: item.command.marker.line + (commandRowCount - 1) + 1 + } + }); } else { - terminalScrollStateSaved = false; - xterm.markTracker.restoreScrollState(); + restoreScrollState(); } }); quickPick.onDidAccept(async () => { @@ -289,13 +304,9 @@ export async function showRunRecentQuickPick( if (quickPick.keyMods.alt) { instance.focus(); } - terminalScrollStateSaved = false; - instance.xterm?.markTracker.restoreScrollState(); - }); - quickPick.onDidHide(() => { - terminalScrollStateSaved = false; - instance.xterm?.markTracker.restoreScrollState(); + restoreScrollState(); }); + quickPick.onDidHide(() => restoreScrollState()); if (value) { quickPick.value = value; }