Skip to content

Commit 99e7feb

Browse files
committed
fix: preserve chat input focus during automated file editing (#4574)
- Add preserveFocus: true to showTextDocument call in DiffViewProvider - Prevents focus from being stolen from chat input during auto-mode file edits - Update tests to reflect new expected behavior Fixes #4574
1 parent 24eb6e4 commit 99e7feb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export class DiffViewProvider {
504504
// Pre-open the file as a text document to ensure it doesn't open in preview mode
505505
// This fixes issues with files that have custom editor associations (like markdown preview)
506506
vscode.window
507-
.showTextDocument(uri, { preview: false, viewColumn: vscode.ViewColumn.Active })
507+
.showTextDocument(uri, { preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true })
508508
.then(() => {
509509
// Execute the diff command after ensuring the file is open as text
510510
return vscode.commands.executeCommand(

src/integrations/editor/__tests__/DiffViewProvider.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe("DiffViewProvider", () => {
176176
// Mock showTextDocument to track when it's called
177177
vi.mocked(vscode.window.showTextDocument).mockImplementation(async (uri, options) => {
178178
callOrder.push("showTextDocument")
179-
expect(options).toEqual({ preview: false, viewColumn: vscode.ViewColumn.Active })
179+
expect(options).toEqual({ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true })
180180
return mockEditor as any
181181
})
182182

@@ -211,7 +211,7 @@ describe("DiffViewProvider", () => {
211211
// Verify that showTextDocument was called with preview: false
212212
expect(vscode.window.showTextDocument).toHaveBeenCalledWith(
213213
expect.objectContaining({ fsPath: `${mockCwd}/test.md` }),
214-
{ preview: false, viewColumn: vscode.ViewColumn.Active },
214+
{ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true },
215215
)
216216

217217
// Verify that the diff command was executed

0 commit comments

Comments
 (0)