@@ -46,6 +46,9 @@ import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarA
46
46
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
47
47
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
48
48
import { IHostService } from 'vs/workbench/services/host/browser/host' ;
49
+ import { ICodeEditor , getCodeEditor } from 'vs/editor/browser/editorBrowser' ;
50
+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
51
+ import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
49
52
50
53
const CONTEXT_VOICE_CHAT_GETTING_READY = new RawContextKey < boolean > ( 'voiceChatGettingReady' , false , { type : 'boolean' , description : localize ( 'voiceChatGettingReady' , "True when getting ready for receiving voice input from the microphone for voice chat." ) } ) ;
51
54
const CONTEXT_VOICE_CHAT_IN_PROGRESS = new RawContextKey < boolean > ( 'voiceChatInProgress' , false , { type : 'boolean' , description : localize ( 'voiceChatInProgress' , "True when voice recording from microphone is in progress for voice chat." ) } ) ;
@@ -73,6 +76,15 @@ interface IVoiceChatSessionController {
73
76
clearInputPlaceholder ( ) : void ;
74
77
}
75
78
79
+ function getFocusedCodeEditor ( editorService : IEditorService , codeEditorService : ICodeEditorService ) : ICodeEditor | null {
80
+ const codeEditor = getCodeEditor ( codeEditorService . getFocusedCodeEditor ( ) ) ;
81
+ if ( codeEditor && ! ( codeEditor instanceof EmbeddedCodeEditorWidget ) ) {
82
+ return codeEditor ;
83
+ }
84
+
85
+ return getCodeEditor ( editorService . activeTextEditorControl ) ;
86
+ }
87
+
76
88
class VoiceChatSessionControllerFactory {
77
89
78
90
static create ( accessor : ServicesAccessor , context : 'inline' ) : Promise < IVoiceChatSessionController | undefined > ;
@@ -87,6 +99,7 @@ class VoiceChatSessionControllerFactory {
87
99
const codeEditorService = accessor . get ( ICodeEditorService ) ;
88
100
const quickChatService = accessor . get ( IQuickChatService ) ;
89
101
const layoutService = accessor . get ( IWorkbenchLayoutService ) ;
102
+ const editorService = accessor . get ( IEditorService ) ;
90
103
91
104
// Currently Focused Context
92
105
if ( context === 'focused' ) {
@@ -114,7 +127,7 @@ class VoiceChatSessionControllerFactory {
114
127
}
115
128
116
129
// Try with the inline chat
117
- const activeCodeEditor = codeEditorService . getFocusedCodeEditor ( ) ;
130
+ const activeCodeEditor = getFocusedCodeEditor ( editorService , codeEditorService ) ;
118
131
if ( activeCodeEditor ) {
119
132
const inlineChat = InlineChatController . get ( activeCodeEditor ) ;
120
133
if ( inlineChat ?. hasFocus ( ) ) {
@@ -136,7 +149,7 @@ class VoiceChatSessionControllerFactory {
136
149
137
150
// Inline Chat
138
151
if ( context === 'inline' ) {
139
- const activeCodeEditor = codeEditorService . getFocusedCodeEditor ( ) ;
152
+ const activeCodeEditor = getFocusedCodeEditor ( editorService , codeEditorService ) ;
140
153
if ( activeCodeEditor ) {
141
154
const inlineChat = InlineChatController . get ( activeCodeEditor ) ;
142
155
if ( inlineChat ) {
@@ -774,6 +787,7 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
774
787
@IEditorGroupsService private readonly editorGroupService : IEditorGroupsService ,
775
788
@IInstantiationService instantiationService : IInstantiationService ,
776
789
@ICodeEditorService private readonly codeEditorService : ICodeEditorService ,
790
+ @IEditorService private readonly editorService : IEditorService ,
777
791
@IHostService private readonly hostService : IHostService
778
792
) {
779
793
super ( ) ;
@@ -889,7 +903,7 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
889
903
case KeywordActivationContribution . SETTINGS_VALUE . QUICK_CHAT :
890
904
return QuickVoiceChatAction . ID ;
891
905
case KeywordActivationContribution . SETTINGS_VALUE . CHAT_IN_CONTEXT :
892
- if ( this . codeEditorService . getFocusedCodeEditor ( ) ) {
906
+ if ( getFocusedCodeEditor ( this . editorService , this . codeEditorService ) ) {
893
907
return InlineVoiceChatAction . ID ;
894
908
}
895
909
default :
0 commit comments