4
4
*--------------------------------------------------------------------------------------------*/
5
5
import { CancellationToken } from '../../../../base/common/cancellation.js' ;
6
6
import { Emitter , Event } from '../../../../base/common/event.js' ;
7
- import { DisposableMap , DisposableStore , IDisposable , MutableDisposable , toDisposable } from '../../../../base/common/lifecycle.js' ;
7
+ import { DisposableStore , IDisposable , MutableDisposable , toDisposable } from '../../../../base/common/lifecycle.js' ;
8
8
import { Schemas } from '../../../../base/common/network.js' ;
9
9
import { URI } from '../../../../base/common/uri.js' ;
10
10
import { generateUuid } from '../../../../base/common/uuid.js' ;
11
- import { IActiveCodeEditor , ICodeEditor } from '../../../../editor/browser/editorBrowser.js' ;
11
+ import { IActiveCodeEditor , ICodeEditor , isCodeEditor , isCompositeEditor , isDiffEditor } from '../../../../editor/browser/editorBrowser.js' ;
12
12
import { Range } from '../../../../editor/common/core/range.js' ;
13
13
import { IValidEditOperation } from '../../../../editor/common/model.js' ;
14
14
import { createTextBufferFactoryFromSnapshot } from '../../../../editor/common/model/textModel.js' ;
@@ -22,16 +22,14 @@ import { ITelemetryService } from '../../../../platform/telemetry/common/telemet
22
22
import { DEFAULT_EDITOR_ASSOCIATION } from '../../../common/editor.js' ;
23
23
import { ChatAgentLocation , IChatAgentService } from '../../chat/common/chatAgents.js' ;
24
24
import { IChatService } from '../../chat/common/chatService.js' ;
25
- import { CTX_INLINE_CHAT_HAS_AGENT , CTX_INLINE_CHAT_POSSIBLE , EditMode , INLINE_CHAT_ID } from '../common/inlineChat.js' ;
25
+ import { CTX_INLINE_CHAT_HAS_AGENT , CTX_INLINE_CHAT_POSSIBLE , EditMode } from '../common/inlineChat.js' ;
26
26
import { IEditorService } from '../../../services/editor/common/editorService.js' ;
27
27
import { UntitledTextEditorInput } from '../../../services/untitled/common/untitledTextEditorInput.js' ;
28
28
import { HunkData , Session , SessionWholeRange , StashedSession , TelemetryData , TelemetryDataClassification } from './inlineChatSession.js' ;
29
29
import { IInlineChatSessionEndEvent , IInlineChatSessionEvent , IInlineChatSessionService , ISessionKeyComputer } from './inlineChatSessionService.js' ;
30
30
import { isEqual } from '../../../../base/common/resources.js' ;
31
31
import { ILanguageService } from '../../../../editor/common/languages/language.js' ;
32
32
import { ITextFileService } from '../../../services/textfile/common/textfiles.js' ;
33
- import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js' ;
34
- import { EditorOption } from '../../../../editor/common/config/editorOptions.js' ;
35
33
36
34
37
35
type SessionData = {
@@ -328,7 +326,6 @@ export class InlineChatEnabler {
328
326
constructor (
329
327
@IContextKeyService contextKeyService : IContextKeyService ,
330
328
@IChatAgentService chatAgentService : IChatAgentService ,
331
- @ICodeEditorService codeEditorService : ICodeEditorService ,
332
329
@IEditorService editorService : IEditorService ,
333
330
) {
334
331
this . _ctxHasProvider = CTX_INLINE_CHAT_HAS_AGENT . bindTo ( contextKeyService ) ;
@@ -343,25 +340,13 @@ export class InlineChatEnabler {
343
340
updateAgent ( ) ;
344
341
345
342
const updateEditor = ( ) => {
346
- const editor = codeEditorService . getFocusedCodeEditor ( ) ?? codeEditorService . getActiveCodeEditor ( ) ;
347
-
348
- this . _ctxPossible . set ( Boolean ( editor
349
- && editor . getContribution ( INLINE_CHAT_ID )
350
- && editor . hasWidgetFocus ( )
351
- && ! editor . getOption ( EditorOption . readOnly )
352
- && ! editor . isSimpleWidget
353
- ) ) ;
343
+ const ctrl = editorService . activeEditorPane ?. getControl ( ) ;
344
+ const isCodeEditorLike = isCodeEditor ( ctrl ) || isDiffEditor ( ctrl ) || isCompositeEditor ( ctrl ) ;
345
+ this . _ctxPossible . set ( isCodeEditorLike ) ;
354
346
} ;
355
347
356
348
this . _store . add ( editorService . onDidActiveEditorChange ( updateEditor ) ) ;
357
-
358
- const editorDisposables = this . _store . add ( new DisposableMap < ICodeEditor > ( ) ) ;
359
- this . _store . add ( codeEditorService . onCodeEditorAdd ( e => {
360
- editorDisposables . set ( e , Event . any ( e . onDidBlurEditorWidget , e . onDidFocusEditorWidget ) ( updateEditor ) ) ;
361
- } ) ) ;
362
- this . _store . add ( codeEditorService . onCodeEditorRemove ( e => {
363
- editorDisposables . deleteAndDispose ( e ) ;
364
- } ) ) ;
349
+ updateEditor ( ) ;
365
350
}
366
351
367
352
dispose ( ) {
0 commit comments