@@ -28,6 +28,8 @@ import { SuggestAddon } from './terminalSuggestAddon.js';
28
28
import { TerminalClipboardContribution } from '../../clipboard/browser/terminal.clipboard.contribution.js' ;
29
29
import { PwshCompletionProviderAddon } from './pwshCompletionProviderAddon.js' ;
30
30
import { SimpleSuggestContext } from '../../../../services/suggest/browser/simpleSuggestWidget.js' ;
31
+ import { SuggestDetailsClassName } from '../../../../services/suggest/browser/simpleSuggestWidgetDetails.js' ;
32
+ import { EditorContextKeys } from '../../../../../editor/common/editorContextKeys.js' ;
31
33
32
34
registerSingleton ( ITerminalCompletionService , TerminalCompletionService , InstantiationType . Delayed ) ;
33
35
@@ -153,7 +155,16 @@ class TerminalSuggestContribution extends DisposableStore implements ITerminalCo
153
155
addon . setContainerWithOverflow ( dom . findParentWithClass ( xterm . element ! , 'panel' ) ! ) ;
154
156
}
155
157
addon . setScreen ( xterm . element ! . querySelector ( '.xterm-screen' ) ! ) ;
156
- this . add ( this . _ctx . instance . onDidBlur ( ( ) => addon . hideSuggestWidget ( ) ) ) ;
158
+
159
+ this . add ( dom . addDisposableListener ( this . _ctx . instance . domElement , dom . EventType . FOCUS_OUT , ( e ) => {
160
+ const focusedElement = e . relatedTarget as HTMLElement ;
161
+ if ( focusedElement . className === SuggestDetailsClassName ) {
162
+ // Don't hide the suggest widget if the focus is moving to the details
163
+ return ;
164
+ }
165
+ addon . hideSuggestWidget ( ) ;
166
+ } ) ) ;
167
+
157
168
this . add ( addon . onAcceptedCompletion ( async text => {
158
169
this . _ctx . instance . focus ( ) ;
159
170
this . _ctx . instance . sendText ( text , false ) ;
@@ -263,11 +274,25 @@ registerActiveInstanceAction({
263
274
run : ( activeInstance ) => TerminalSuggestContribution . get ( activeInstance ) ?. addon ?. toggleExplainMode ( )
264
275
} ) ;
265
276
277
+ registerActiveInstanceAction ( {
278
+ id : TerminalSuggestCommandId . ToggleDetailsFocus ,
279
+ title : localize2 ( 'workbench.action.terminal.suggestToggleDetailsFocus' , 'Suggest Toggle Suggestion Focus' ) ,
280
+ f1 : false ,
281
+ // HACK: This does not work with a precondition of `TerminalContextKeys.suggestWidgetVisible`, so make sure to not override the editor's keybinding
282
+ precondition : EditorContextKeys . textInputFocus . negate ( ) ,
283
+ keybinding : {
284
+ weight : KeybindingWeight . WorkbenchContrib ,
285
+ primary : KeyMod . CtrlCmd | KeyMod . Alt | KeyCode . Space ,
286
+ mac : { primary : KeyMod . WinCtrl | KeyMod . Alt | KeyCode . Space }
287
+ } ,
288
+ run : ( activeInstance ) => TerminalSuggestContribution . get ( activeInstance ) ?. addon ?. toggleSuggestionFocus ( )
289
+ } ) ;
290
+
266
291
registerActiveInstanceAction ( {
267
292
id : TerminalSuggestCommandId . ToggleDetails ,
268
293
title : localize2 ( 'workbench.action.terminal.suggestToggleDetails' , 'Suggest Toggle Details' ) ,
269
294
f1 : false ,
270
- precondition : ContextKeyExpr . and ( ContextKeyExpr . or ( TerminalContextKeys . processSupported , TerminalContextKeys . terminalHasBeenCreated ) , TerminalContextKeys . focus , TerminalContextKeys . isOpen , TerminalContextKeys . suggestWidgetVisible , SimpleSuggestContext . HasFocusedSuggestion ) ,
295
+ precondition : ContextKeyExpr . and ( ContextKeyExpr . or ( TerminalContextKeys . processSupported , TerminalContextKeys . terminalHasBeenCreated ) , TerminalContextKeys . isOpen , TerminalContextKeys . focus , TerminalContextKeys . suggestWidgetVisible , SimpleSuggestContext . HasFocusedSuggestion ) ,
271
296
keybinding : {
272
297
// HACK: Force weight to be higher than that to start terminal chat
273
298
weight : KeybindingWeight . ExternalExtension + 2 ,
0 commit comments