@@ -10,7 +10,6 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
10
10
import { toErrorMessage } from 'vs/base/common/errorMessage' ;
11
11
import { Emitter , Event } from 'vs/base/common/event' ;
12
12
import { DisposableStore , IDisposable , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
13
- import { isEqual } from 'vs/base/common/resources' ;
14
13
import { StopWatch } from 'vs/base/common/stopwatch' ;
15
14
import { assertType } from 'vs/base/common/types' ;
16
15
import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
@@ -35,8 +34,6 @@ import { InlineChatZoneWidget } from 'vs/workbench/contrib/inlineChat/browser/in
35
34
import { CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST , CTX_INLINE_CHAT_LAST_FEEDBACK , IInlineChatRequest , IInlineChatResponse , INLINE_CHAT_ID , EditMode , InlineChatResponseFeedbackKind , CTX_INLINE_CHAT_LAST_RESPONSE_TYPE , InlineChatResponseType , CTX_INLINE_CHAT_DID_EDIT , CTX_INLINE_CHAT_HAS_STASHED_SESSION , InlineChateResponseTypes , CTX_INLINE_CHAT_RESPONSE_TYPES } from 'vs/workbench/contrib/inlineChat/common/inlineChat' ;
36
35
import { IChatAccessibilityService , IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
37
36
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
38
- import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
39
- import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
40
37
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
41
38
import { Lazy } from 'vs/base/common/lazy' ;
42
39
@@ -111,7 +108,6 @@ export class InlineChatController implements IEditorContribution {
111
108
@ILogService private readonly _logService : ILogService ,
112
109
@IConfigurationService private readonly _configurationService : IConfigurationService ,
113
110
@IModelService private readonly _modelService : IModelService ,
114
- @INotebookEditorService private readonly _notebookEditorService : INotebookEditorService ,
115
111
@IDialogService private readonly _dialogService : IDialogService ,
116
112
@IContextKeyService contextKeyService : IContextKeyService ,
117
113
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
@@ -144,7 +140,7 @@ export class InlineChatController implements IEditorContribution {
144
140
145
141
dispose ( ) : void {
146
142
this . _stashedSession . clear ( ) ;
147
- this . _finishExistingSession ( ) ;
143
+ this . finishExistingSession ( ) ;
148
144
this . _store . dispose ( ) ;
149
145
this . _log ( 'controller disposed' ) ;
150
146
}
@@ -177,25 +173,13 @@ export class InlineChatController implements IEditorContribution {
177
173
178
174
async run ( options : InlineChatRunOptions | undefined = { } ) : Promise < void > {
179
175
this . _log ( 'session starting' ) ;
180
- await this . _finishExistingSession ( ) ;
176
+ await this . finishExistingSession ( ) ;
181
177
this . _stashedSession . clear ( ) ;
182
178
183
179
await this . _nextState ( State . CREATE_SESSION , options ) ;
184
180
this . _log ( 'session done or paused' ) ;
185
181
}
186
182
187
- private async _finishExistingSession ( ) : Promise < void > {
188
- if ( this . _activeSession ) {
189
- if ( this . _activeSession . editMode === EditMode . Preview ) {
190
- this . _log ( 'finishing existing session, using CANCEL' , this . _activeSession . editMode ) ;
191
- this . cancelSession ( ) ;
192
- } else {
193
- this . _log ( 'finishing existing session, using APPLY' , this . _activeSession . editMode ) ;
194
- this . acceptSession ( ) ;
195
- }
196
- }
197
- }
198
-
199
183
// ---- state machine
200
184
201
185
private _showWidget ( initialRender : boolean = false ) {
@@ -296,8 +280,6 @@ export class InlineChatController implements IEditorContribution {
296
280
// hide/cancel inline completions when invoking IE
297
281
InlineCompletionsController . get ( this . _editor ) ?. hide ( ) ;
298
282
299
- this . _cancelNotebookSiblingEditors ( ) ;
300
-
301
283
this . _sessionStore . clear ( ) ;
302
284
303
285
const wholeRangeDecoration = this . _editor . createDecorationsCollection ( ) ;
@@ -348,7 +330,7 @@ export class InlineChatController implements IEditorContribution {
348
330
349
331
if ( editIsOutsideOfWholeRange ) {
350
332
this . _log ( 'text changed outside of whole range, FINISH session' ) ;
351
- this . _finishExistingSession ( ) ;
333
+ this . finishExistingSession ( ) ;
352
334
}
353
335
} ) ) ;
354
336
@@ -375,35 +357,6 @@ export class InlineChatController implements IEditorContribution {
375
357
return result ;
376
358
}
377
359
378
- private _cancelNotebookSiblingEditors ( ) : void {
379
- if ( ! this . _editor . hasModel ( ) ) {
380
- return ;
381
- }
382
- const candidate = CellUri . parse ( this . _editor . getModel ( ) . uri ) ;
383
- if ( ! candidate ) {
384
- return ;
385
- }
386
- for ( const editor of this . _notebookEditorService . listNotebookEditors ( ) ) {
387
- if ( isEqual ( editor . textModel ?. uri , candidate . notebook ) ) {
388
- let found = false ;
389
- const editors : ICodeEditor [ ] = [ ] ;
390
- for ( const [ , codeEditor ] of editor . codeEditors ) {
391
- editors . push ( codeEditor ) ;
392
- found = codeEditor === this . _editor || found ;
393
- }
394
- if ( found ) {
395
- // found the this editor in the outer notebook editor -> make sure to
396
- // cancel all sibling sessions
397
- for ( const editor of editors ) {
398
- if ( editor !== this . _editor ) {
399
- InlineChatController . get ( editor ) ?. _finishExistingSession ( ) ;
400
- }
401
- }
402
- break ;
403
- }
404
- }
405
- }
406
- }
407
360
408
361
private async [ State . WAIT_FOR_INPUT ] ( options : InlineChatRunOptions ) : Promise < State . ACCEPT | State . CANCEL | State . PAUSE | State . WAIT_FOR_INPUT | State . MAKE_REQUEST > {
409
362
assertType ( this . _activeSession ) ;
@@ -818,6 +771,18 @@ export class InlineChatController implements IEditorContribution {
818
771
return result ;
819
772
}
820
773
774
+ async finishExistingSession ( ) : Promise < void > {
775
+ if ( this . _activeSession ) {
776
+ if ( this . _activeSession . editMode === EditMode . Preview ) {
777
+ this . _log ( 'finishing existing session, using CANCEL' , this . _activeSession . editMode ) ;
778
+ this . cancelSession ( ) ;
779
+ } else {
780
+ this . _log ( 'finishing existing session, using APPLY' , this . _activeSession . editMode ) ;
781
+ this . acceptSession ( ) ;
782
+ }
783
+ }
784
+ }
785
+
821
786
unstashLastSession ( ) : Session | undefined {
822
787
return this . _stashedSession . value ?. unstash ( ) ;
823
788
}
0 commit comments