-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: preserve chat input focus during automated file editing (#4574) #5282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -503,8 +503,9 @@ export class DiffViewProvider { | |
|
|
||
| // Pre-open the file as a text document to ensure it doesn't open in preview mode | ||
| // This fixes issues with files that have custom editor associations (like markdown preview) | ||
| const showOptions = { preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that
Is it intentional that these other locations don't preserve focus? If they could also cause focus issues during automated workflows, would it make sense to apply the same pattern there for consistency? |
||
| vscode.window | ||
| .showTextDocument(uri, { preview: false, viewColumn: vscode.ViewColumn.Active }) | ||
| .showTextDocument(uri, showOptions) | ||
| .then(() => { | ||
| // Execute the diff command after ensuring the file is open as text | ||
| return vscode.commands.executeCommand( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,7 +176,13 @@ describe("DiffViewProvider", () => { | |
| // Mock showTextDocument to track when it's called | ||
| vi.mocked(vscode.window.showTextDocument).mockImplementation(async (uri, options) => { | ||
| callOrder.push("showTextDocument") | ||
| expect(options).toEqual({ preview: false, viewColumn: vscode.ViewColumn.Active }) | ||
| expect(options).toEqual( | ||
| expect.objectContaining({ | ||
| preview: false, | ||
| viewColumn: vscode.ViewColumn.Active, | ||
| preserveFocus: true, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the tests correctly verify that I understand this might be challenging in a unit test environment, but it could be valuable for preventing regressions of this specific bug. Perhaps this could be added to the E2E test suite if it's not feasible here? |
||
| }), | ||
| ) | ||
| return mockEditor as any | ||
| }) | ||
|
|
||
|
|
@@ -211,7 +217,7 @@ describe("DiffViewProvider", () => { | |
| // Verify that showTextDocument was called with preview: false | ||
| expect(vscode.window.showTextDocument).toHaveBeenCalledWith( | ||
| expect.objectContaining({ fsPath: `${mockCwd}/test.md` }), | ||
| { preview: false, viewColumn: vscode.ViewColumn.Active }, | ||
| expect.objectContaining({ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true }), | ||
| ) | ||
|
|
||
| // Verify that the diff command was executed | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're now also preserving focus to fix the chat input issue, would it be helpful to update this comment to reflect both purposes? Something like: