4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { KeyCode , KeyMod } from '../../../../../base/common/keyCodes.js' ;
7
- import { Disposable } from '../../../../../base/common/lifecycle.js' ;
7
+ import { Disposable , DisposableStore } from '../../../../../base/common/lifecycle.js' ;
8
8
import { localize2 } from '../../../../../nls.js' ;
9
9
import { AccessibleViewProviderId } from '../../../../../platform/accessibility/browser/accessibleView.js' ;
10
10
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../../../../../platform/accessibility/common/accessibility.js' ;
@@ -129,7 +129,7 @@ registerActiveInstanceAction({
129
129
}
130
130
} ) ;
131
131
132
- registerActiveInstanceAction ( {
132
+ registerTerminalAction ( {
133
133
id : TerminalHistoryCommandId . RunRecentCommand ,
134
134
title : localize2 ( 'workbench.action.terminal.runRecentCommand' , 'Run Recent Command...' ) ,
135
135
precondition,
@@ -146,7 +146,22 @@ registerActiveInstanceAction({
146
146
weight : KeybindingWeight . WorkbenchContrib
147
147
}
148
148
] ,
149
- run : async ( activeInstance , c ) => {
149
+ run : async ( c , accessor ) => {
150
+ let activeInstance = c . service . activeInstance ;
151
+ // If an instanec doesn't exist, create one and wait for shell type to be set
152
+ if ( ! activeInstance ) {
153
+ const newInstance = activeInstance = await c . service . getActiveOrCreateInstance ( ) ;
154
+ await c . service . revealActiveTerminal ( ) ;
155
+ const store = new DisposableStore ( ) ;
156
+ const wasDisposedPrematurely = await new Promise < boolean > ( r => {
157
+ store . add ( newInstance . onDidChangeShellType ( ( ) => r ( false ) ) ) ;
158
+ store . add ( newInstance . onDisposed ( ( ) => r ( true ) ) ) ;
159
+ } ) ;
160
+ store . dispose ( ) ;
161
+ if ( wasDisposedPrematurely ) {
162
+ return ;
163
+ }
164
+ }
150
165
const history = TerminalHistoryContribution . get ( activeInstance ) ;
151
166
if ( ! history ) {
152
167
return ;
0 commit comments