@@ -23,7 +23,9 @@ import { ITextModel, IValidEditOperation } from 'vs/editor/common/model';
2323import { Schemas } from 'vs/base/common/network' ;
2424import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
2525import { generateUuid } from 'vs/base/common/uuid' ;
26- import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
26+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
27+ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput' ;
28+ import { DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor' ;
2729
2830type SessionData = {
2931 editor : ICodeEditor ;
@@ -59,7 +61,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
5961 @IEditorWorkerService private readonly _editorWorkerService : IEditorWorkerService ,
6062 @ILogService private readonly _logService : ILogService ,
6163 @IInstantiationService private readonly _instaService : IInstantiationService ,
62- @ITextFileService private readonly _textFileService : ITextFileService ,
64+ @IEditorService private readonly _editorService : IEditorService ,
6365 ) { }
6466
6567 dispose ( ) {
@@ -125,16 +127,13 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
125127 targetUri . with ( { scheme : Schemas . vscode , authority : 'inline-chat' , path : '' , query : new URLSearchParams ( { id, 'textModel0' : '' } ) . toString ( ) } ) , true
126128 ) ) ;
127129
128- // untitled documents are special
130+ // untitled documents are special and we are releasing their session when their last editor closes
129131 if ( targetUri . scheme === Schemas . untitled ) {
130- const untitledTextModel = this . _textFileService . untitled . get ( targetUri ) ;
131- if ( untitledTextModel ) {
132- store . add ( untitledTextModel . onDidChangeDirty ( ( ) => {
133- if ( ! untitledTextModel . isDirty ( ) ) {
134- this . releaseSession ( session ) ;
135- }
136- } ) ) ;
137- }
132+ store . add ( this . _editorService . onDidCloseEditor ( ( ) => {
133+ if ( ! this . _editorService . isOpened ( { resource : targetUri , typeId : UntitledTextEditorInput . ID , editorId : DEFAULT_EDITOR_ASSOCIATION . id } ) ) {
134+ this . releaseSession ( session ) ;
135+ }
136+ } ) ) ;
138137 }
139138
140139 let wholeRange = options . wholeRange ;
0 commit comments