@@ -164,6 +164,10 @@ abstract class InsertCodeBlockAction extends ChatCodeBlockAction {
164
164
return { edits : [ new ResourceTextEdit ( activeModel . uri , { range, text } ) ] } ;
165
165
}
166
166
167
+ protected get showPreview ( ) {
168
+ return false ;
169
+ }
170
+
167
171
private async handleTextEditor ( accessor : ServicesAccessor , codeEditor : IActiveCodeEditor , codeBlockActionContext : ICodeBlockActionContext ) {
168
172
const bulkEditService = accessor . get ( IBulkEditService ) ;
169
173
const codeEditorService = accessor . get ( ICodeEditorService ) ;
@@ -172,9 +176,15 @@ abstract class InsertCodeBlockAction extends ChatCodeBlockAction {
172
176
const result = await this . computeEdits ( accessor , codeEditor , codeBlockActionContext ) ;
173
177
this . notifyUserAction ( chatService , codeBlockActionContext , result ) ;
174
178
175
- const showWithPreview = await this . applyWithInlinePreview ( codeEditorService , result . edits , codeEditor ) ;
176
- if ( ! showWithPreview ) {
177
- await bulkEditService . apply ( result . edits , { showPreview : true } ) ;
179
+ if ( this . showPreview ) {
180
+ const showWithPreview = await this . applyWithInlinePreview ( codeEditorService , result . edits , codeEditor ) ;
181
+ if ( ! showWithPreview ) {
182
+ await bulkEditService . apply ( result . edits , { showPreview : true } ) ;
183
+ const activeModel = codeEditor . getModel ( ) ;
184
+ codeEditorService . listCodeEditors ( ) . find ( editor => editor . getModel ( ) ?. uri . toString ( ) === activeModel . uri . toString ( ) ) ?. focus ( ) ;
185
+ }
186
+ } else {
187
+ await bulkEditService . apply ( result . edits ) ;
178
188
const activeModel = codeEditor . getModel ( ) ;
179
189
codeEditorService . listCodeEditors ( ) . find ( editor => editor . getModel ( ) ?. uri . toString ( ) === activeModel . uri . toString ( ) ) ?. focus ( ) ;
180
190
}
@@ -476,6 +486,11 @@ export function registerChatCodeBlockActions() {
476
486
// fall back to inserting the code block as is
477
487
return super . computeEdits ( accessor , codeEditor , codeBlockActionContext ) ;
478
488
}
489
+
490
+ protected override get showPreview ( ) {
491
+ return true ;
492
+ }
493
+
479
494
} ) ;
480
495
481
496
registerAction2 ( class SmartApplyInEditorAction extends InsertCodeBlockAction {
0 commit comments