@@ -46,6 +46,9 @@ import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarA
4646import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
4747import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
4848import { 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' ;
4952
5053const 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." ) } ) ;
5154const 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 {
7376 clearInputPlaceholder ( ) : void ;
7477}
7578
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+
7688class VoiceChatSessionControllerFactory {
7789
7890 static create ( accessor : ServicesAccessor , context : 'inline' ) : Promise < IVoiceChatSessionController | undefined > ;
@@ -87,6 +99,7 @@ class VoiceChatSessionControllerFactory {
8799 const codeEditorService = accessor . get ( ICodeEditorService ) ;
88100 const quickChatService = accessor . get ( IQuickChatService ) ;
89101 const layoutService = accessor . get ( IWorkbenchLayoutService ) ;
102+ const editorService = accessor . get ( IEditorService ) ;
90103
91104 // Currently Focused Context
92105 if ( context === 'focused' ) {
@@ -114,7 +127,7 @@ class VoiceChatSessionControllerFactory {
114127 }
115128
116129 // Try with the inline chat
117- const activeCodeEditor = codeEditorService . getFocusedCodeEditor ( ) ;
130+ const activeCodeEditor = getFocusedCodeEditor ( editorService , codeEditorService ) ;
118131 if ( activeCodeEditor ) {
119132 const inlineChat = InlineChatController . get ( activeCodeEditor ) ;
120133 if ( inlineChat ?. hasFocus ( ) ) {
@@ -136,7 +149,7 @@ class VoiceChatSessionControllerFactory {
136149
137150 // Inline Chat
138151 if ( context === 'inline' ) {
139- const activeCodeEditor = codeEditorService . getFocusedCodeEditor ( ) ;
152+ const activeCodeEditor = getFocusedCodeEditor ( editorService , codeEditorService ) ;
140153 if ( activeCodeEditor ) {
141154 const inlineChat = InlineChatController . get ( activeCodeEditor ) ;
142155 if ( inlineChat ) {
@@ -774,6 +787,7 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
774787 @IEditorGroupsService private readonly editorGroupService : IEditorGroupsService ,
775788 @IInstantiationService instantiationService : IInstantiationService ,
776789 @ICodeEditorService private readonly codeEditorService : ICodeEditorService ,
790+ @IEditorService private readonly editorService : IEditorService ,
777791 @IHostService private readonly hostService : IHostService
778792 ) {
779793 super ( ) ;
@@ -889,7 +903,7 @@ export class KeywordActivationContribution extends Disposable implements IWorkbe
889903 case KeywordActivationContribution . SETTINGS_VALUE . QUICK_CHAT :
890904 return QuickVoiceChatAction . ID ;
891905 case KeywordActivationContribution . SETTINGS_VALUE . CHAT_IN_CONTEXT :
892- if ( this . codeEditorService . getFocusedCodeEditor ( ) ) {
906+ if ( getFocusedCodeEditor ( this . editorService , this . codeEditorService ) ) {
893907 return InlineVoiceChatAction . ID ;
894908 }
895909 default :
0 commit comments