@@ -10,7 +10,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
10
10
import { mock } from 'vs/base/test/common/mock' ;
11
11
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils' ;
12
12
import { TestDiffProviderFactoryService } from 'vs/editor/browser/diff/testDiffProviderFactoryService' ;
13
- import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
13
+ import { IActiveCodeEditor } from 'vs/editor/browser/editorBrowser' ;
14
14
import { IDiffProviderFactoryService } from 'vs/editor/browser/widget/diffEditor/diffProviderFactoryService' ;
15
15
import { Range } from 'vs/editor/common/core/range' ;
16
16
import { ITextModel } from 'vs/editor/common/model' ;
@@ -81,7 +81,7 @@ suite('InteractiveChatController', function () {
81
81
}
82
82
83
83
const store = new DisposableStore ( ) ;
84
- let editor : ICodeEditor ;
84
+ let editor : IActiveCodeEditor ;
85
85
let model : ITextModel ;
86
86
let ctrl : TestController ;
87
87
// let contextKeys: MockContextKeyService;
@@ -327,4 +327,44 @@ suite('InteractiveChatController', function () {
327
327
await r ;
328
328
assert . strictEqual ( ctrl . getWidgetPosition ( ) , undefined ) ;
329
329
} ) ;
330
+
331
+ test ( '[Bug] Inline Chat\'s streaming pushed broken iterations to the undo stack #2403' , async function ( ) {
332
+
333
+ const d = inlineChatService . addProvider ( {
334
+ debugName : 'Unit Test' ,
335
+ label : 'Unit Test' ,
336
+ prepareInlineChatSession ( ) {
337
+ return {
338
+ id : Math . random ( ) ,
339
+ wholeRange : new Range ( 3 , 1 , 3 , 3 )
340
+ } ;
341
+ } ,
342
+ async provideResponse ( session , request , progress ) {
343
+
344
+ progress . report ( { edits : [ { range : new Range ( 1 , 1 , 1 , 1 ) , text : 'hEllo1\n' } ] } ) ;
345
+ progress . report ( { edits : [ { range : new Range ( 2 , 1 , 2 , 1 ) , text : 'hEllo2\n' } ] } ) ;
346
+
347
+ return {
348
+ id : Math . random ( ) ,
349
+ type : InlineChatResponseType . EditorEdit ,
350
+ edits : [ { range : new Range ( 1 , 1 , 1000 , 1 ) , text : 'Hello1\nHello2\n' } ]
351
+ } ;
352
+ }
353
+ } ) ;
354
+
355
+ const valueThen = editor . getModel ( ) . getValue ( ) ;
356
+
357
+ store . add ( d ) ;
358
+ ctrl = instaService . createInstance ( TestController , editor ) ;
359
+ const p = ctrl . waitFor ( [ ...TestController . INIT_SEQUENCE , State . MAKE_REQUEST , State . APPLY_RESPONSE , State . SHOW_RESPONSE , State . WAIT_FOR_INPUT ] ) ;
360
+ const r = ctrl . run ( { message : 'Hello' , autoSend : true } ) ;
361
+ await p ;
362
+ ctrl . acceptSession ( ) ;
363
+ await r ;
364
+
365
+ assert . strictEqual ( editor . getModel ( ) . getValue ( ) , 'Hello1\nHello2\n' ) ;
366
+
367
+ editor . getModel ( ) . undo ( ) ;
368
+ assert . strictEqual ( editor . getModel ( ) . getValue ( ) , valueThen ) ;
369
+ } ) ;
330
370
} ) ;
0 commit comments