@@ -23,7 +23,9 @@ import { ITextModel, IValidEditOperation } from 'vs/editor/common/model';
23
23
import { Schemas } from 'vs/base/common/network' ;
24
24
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
25
25
import { 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' ;
27
29
28
30
type SessionData = {
29
31
editor : ICodeEditor ;
@@ -59,7 +61,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
59
61
@IEditorWorkerService private readonly _editorWorkerService : IEditorWorkerService ,
60
62
@ILogService private readonly _logService : ILogService ,
61
63
@IInstantiationService private readonly _instaService : IInstantiationService ,
62
- @ITextFileService private readonly _textFileService : ITextFileService ,
64
+ @IEditorService private readonly _editorService : IEditorService ,
63
65
) { }
64
66
65
67
dispose ( ) {
@@ -125,16 +127,13 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
125
127
targetUri . with ( { scheme : Schemas . vscode , authority : 'inline-chat' , path : '' , query : new URLSearchParams ( { id, 'textModel0' : '' } ) . toString ( ) } ) , true
126
128
) ) ;
127
129
128
- // untitled documents are special
130
+ // untitled documents are special and we are releasing their session when their last editor closes
129
131
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
+ } ) ) ;
138
137
}
139
138
140
139
let wholeRange = options . wholeRange ;
0 commit comments