From 7efe326c490dcf85ea2ac8e41969647b3db4b6c3 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 16 Jan 2024 11:34:21 -0800 Subject: [PATCH] better precondition, enable commands to appear in command pallette --- .../contrib/terminal/browser/terminalActions.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index 5e12619c2f1..0f6d1344b7b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -1644,30 +1644,29 @@ export function registerTerminalActions() { } }); - - registerTerminalAction({ + registerActiveInstanceAction({ id: TerminalCommandId.StartSpeechToText, title: { value: localize('workbench.action.startTerminalSpeechToText', "Start Terminal Speech To Text"), original: 'Start Terminal Speech To Text' }, - precondition: ContextKeyExpr.and(HasSpeechProvider, TerminalContextKeys.focus), + precondition: ContextKeyExpr.and(HasSpeechProvider, sharedWhenClause.terminalAvailable), f1: true, - run: (c, accessor) => { + run: (activeInstance, c, accessor) => { const instantiationService = accessor.get(IInstantiationService); TerminalVoiceSession.getInstance(instantiationService).start(); } }); - registerTerminalAction({ + registerActiveInstanceAction({ id: TerminalCommandId.StopSpeechToText, title: { value: localize('workbench.action.stopTerminalSpeechToText', "Stop Terminal Speech To Text"), original: 'Stop Terminal Speech To Text' }, - precondition: ContextKeyExpr.and(HasSpeechProvider, TerminalContextKeys.focus), + precondition: ContextKeyExpr.and(HasSpeechProvider, sharedWhenClause.terminalAvailable), f1: true, - run: (c, accessor) => { + run: (activeInstance, c, accessor) => { const instantiationService = accessor.get(IInstantiationService); TerminalVoiceSession.getInstance(instantiationService).stop(true); }