Skip to content

Commit 5b7d2e1

Browse files
authored
Don't show preview for Insert at cursor (microsoft#226652)
1 parent 3af3e4f commit 5b7d2e1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ abstract class InsertCodeBlockAction extends ChatCodeBlockAction {
164164
return { edits: [new ResourceTextEdit(activeModel.uri, { range, text })] };
165165
}
166166

167+
protected get showPreview() {
168+
return false;
169+
}
170+
167171
private async handleTextEditor(accessor: ServicesAccessor, codeEditor: IActiveCodeEditor, codeBlockActionContext: ICodeBlockActionContext) {
168172
const bulkEditService = accessor.get(IBulkEditService);
169173
const codeEditorService = accessor.get(ICodeEditorService);
@@ -172,9 +176,15 @@ abstract class InsertCodeBlockAction extends ChatCodeBlockAction {
172176
const result = await this.computeEdits(accessor, codeEditor, codeBlockActionContext);
173177
this.notifyUserAction(chatService, codeBlockActionContext, result);
174178

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);
178188
const activeModel = codeEditor.getModel();
179189
codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === activeModel.uri.toString())?.focus();
180190
}
@@ -476,6 +486,11 @@ export function registerChatCodeBlockActions() {
476486
// fall back to inserting the code block as is
477487
return super.computeEdits(accessor, codeEditor, codeBlockActionContext);
478488
}
489+
490+
protected override get showPreview() {
491+
return true;
492+
}
493+
479494
});
480495

481496
registerAction2(class SmartApplyInEditorAction extends InsertCodeBlockAction {

0 commit comments

Comments
 (0)