Skip to content

Commit 857482f

Browse files
committed
Implements Terminal: Run Recent Command when there are no terminals
1 parent bd21c70 commit 857482f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/vs/workbench/contrib/terminalContrib/history/browser/terminal.history.contribution.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ registerActiveInstanceAction({
129129
}
130130
});
131131

132-
registerActiveInstanceAction({
132+
registerTerminalAction({
133133
id: TerminalHistoryCommandId.RunRecentCommand,
134134
title: localize2('workbench.action.terminal.runRecentCommand', 'Run Recent Command...'),
135135
precondition,
@@ -146,7 +146,22 @@ registerActiveInstanceAction({
146146
weight: KeybindingWeight.WorkbenchContrib
147147
}
148148
],
149-
run: async (activeInstance, c) => {
149+
run: async (c, accessor) => {
150+
const activeInstance = await c.service.getActiveOrCreateInstance();
151+
if (!activeInstance.shellType) {
152+
await c.service.revealActiveTerminal();
153+
const wasDisposedPrematurely = await new Promise<boolean>(resolve => {
154+
activeInstance.onDidChangeShellType(() => {
155+
resolve(false);
156+
});
157+
activeInstance.onDisposed(() => {
158+
resolve(true);
159+
});
160+
});
161+
if (wasDisposedPrematurely) {
162+
return;
163+
}
164+
}
150165
const history = TerminalHistoryContribution.get(activeInstance);
151166
if (!history) {
152167
return;

0 commit comments

Comments
 (0)