Skip to content

Commit 8b943b4

Browse files
authored
Merge pull request microsoft#208326 from microsoft/tyriar/208307
Reveal the current session command in run recent
2 parents 2efb6a9 + 47d2d56 commit 8b943b4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export async function showRunRecentQuickPick(
218218
instantiationService.invokeFunction(showRunRecentQuickPick, instance, terminalInRunCommandPicker, type, fuzzySearchToggle.checked ? 'fuzzy' : 'contiguous', quickPick.value);
219219
});
220220
const outputProvider = instantiationService.createInstance(TerminalOutputProvider);
221-
const quickPick = quickInputService.createQuickPick<IQuickPickItem & { rawLabel: string }>();
221+
const quickPick = quickInputService.createQuickPick<Item | IQuickPickItem & { rawLabel: string }>();
222222
const originalItems = items;
223223
quickPick.items = [...originalItems];
224224
quickPick.sortByLabel = false;
@@ -258,6 +258,24 @@ export async function showRunRecentQuickPick(
258258
await instantiationService.invokeFunction(showRunRecentQuickPick, instance, terminalInRunCommandPicker, type, filterMode, value);
259259
}
260260
});
261+
let terminalScrollStateSaved = false;
262+
quickPick.onDidChangeActive(async () => {
263+
const xterm = instance.xterm;
264+
if (!xterm) {
265+
return;
266+
}
267+
const [item] = quickPick.activeItems;
268+
if ('command' in item && item.command) {
269+
if (!terminalScrollStateSaved) {
270+
xterm.markTracker.saveScrollState();
271+
terminalScrollStateSaved = true;
272+
}
273+
xterm.markTracker.revealCommand(item.command);
274+
} else {
275+
terminalScrollStateSaved = false;
276+
xterm.markTracker.restoreScrollState();
277+
}
278+
});
261279
quickPick.onDidAccept(async () => {
262280
const result = quickPick.activeItems[0];
263281
let text: string;
@@ -271,6 +289,12 @@ export async function showRunRecentQuickPick(
271289
if (quickPick.keyMods.alt) {
272290
instance.focus();
273291
}
292+
terminalScrollStateSaved = false;
293+
instance.xterm?.markTracker.restoreScrollState();
294+
});
295+
quickPick.onDidHide(() => {
296+
terminalScrollStateSaved = false;
297+
instance.xterm?.markTracker.restoreScrollState();
274298
});
275299
if (value) {
276300
quickPick.value = value;

0 commit comments

Comments
 (0)