5
5
6
6
import { isEqual } from 'vs/base/common/resources' ;
7
7
import { URI } from 'vs/base/common/uri' ;
8
- import { Event } from 'vs/base/common/event' ;
8
+ import { Emitter , Event } from 'vs/base/common/event' ;
9
9
import { ResourceEdit , ResourceFileEdit , ResourceTextEdit } from 'vs/editor/browser/services/bulkEditService' ;
10
10
import { TextEdit } from 'vs/editor/common/languages' ;
11
11
import { IModelDeltaDecoration , ITextModel } from 'vs/editor/common/model' ;
@@ -357,6 +357,8 @@ export const IInlineChatSessionService = createDecorator<IInlineChatSessionServi
357
357
export interface IInlineChatSessionService {
358
358
_serviceBrand : undefined ;
359
359
360
+ onWillStartSession : Event < URI > ;
361
+
360
362
createSession ( editor : IActiveCodeEditor , options : { editMode : EditMode ; wholeRange ?: IRange } , token : CancellationToken ) : Promise < Session | undefined > ;
361
363
362
364
getSession ( editor : ICodeEditor , uri : URI ) : Session | undefined ;
@@ -379,6 +381,9 @@ export class InlineChatSessionService implements IInlineChatSessionService {
379
381
380
382
declare _serviceBrand : undefined ;
381
383
384
+ private readonly _onWillStartSession = new Emitter < URI > ( ) ;
385
+ readonly onWillStartSession : Event < URI > = this . _onWillStartSession . event ;
386
+
382
387
private readonly _sessions = new Map < string , SessionData > ( ) ;
383
388
private readonly _keyComputers = new Map < string , ISessionKeyComputer > ( ) ;
384
389
private _recordings : Recording [ ] = [ ] ;
@@ -391,6 +396,12 @@ export class InlineChatSessionService implements IInlineChatSessionService {
391
396
@ILogService private readonly _logService : ILogService ,
392
397
) { }
393
398
399
+ dispose ( ) {
400
+ this . _onWillStartSession . dispose ( ) ;
401
+ this . _sessions . forEach ( x => x . store . dispose ( ) ) ;
402
+ this . _sessions . clear ( ) ;
403
+ }
404
+
394
405
395
406
async createSession ( editor : IActiveCodeEditor , options : { editMode : EditMode ; wholeRange ?: Range } , token : CancellationToken ) : Promise < Session | undefined > {
396
407
@@ -400,6 +411,8 @@ export class InlineChatSessionService implements IInlineChatSessionService {
400
411
return undefined ;
401
412
}
402
413
414
+ this . _onWillStartSession . fire ( editor . getModel ( ) . uri ) ;
415
+
403
416
const textModel = editor . getModel ( ) ;
404
417
const selection = editor . getSelection ( ) ;
405
418
let raw : IInlineChatSession | undefined | null ;
0 commit comments