editor: Fix jumbled auto-imports when completing with multiple cursors#50320
editor: Fix jumbled auto-imports when completing with multiple cursors#50320SomeoneToIgnore merged 1 commit intozed-industries:mainfrom
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @theonly1me on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Just bumping this, this bug is pretty annoying when performing refactors, would be great if someone can take a look at the fix! |
|
https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#sending-changes mentions that the tests have to be included, this alone (missing in this PR) is worth a thousand bumps. |
@SomeoneToIgnore Thanks for responding, I've added a unit test now - 0c0c741 (updated test, so the scenario is more realistic). To clarify, I did review CONTRIBUTING.md as well as the PR template before opening this PR. The guideline says:
And the PR template says:
Since this is an editor change, I included before / after video recordings in the description, which satisfies that criteria. I understand that a unit test may be more desirable, but the original PR wasn't missing what the guidelines ask for. |
|
Superb, thank you so much for the quick update. Videos are great overall and very useful, thank you for adding these, yet their purpose is to assess visual changes mostly (e.g. mouse interactions with the UI, tree-sitter highlight updates, UI changes, etc.). The logic is great to show this way, but it's definitely not enough to call it "tested" after a single video, as the code is changed quite rapidly with dozens of PRs each day. |
@SomeoneToIgnore that's fair, I'll make sure to add unit tests for any future PRs. |
|
The |
|
This is a test flak, the test had been added recently and needs some taking care of, the author seems to be aware of this. |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Great, thank you for this.
Let's not wreck agent evals though, so one more change is needed.
crates/agent/src/edit_agent/evals/fixtures/disable_cursor_blinking/before.rs
Outdated
Show resolved
Hide resolved
When accepting an autocomplete suggestion with multiple active cursors using `CMD+D`, Zed applies the primary completion edit to all cursors. However, the overlap check for LSP `additionalTextEdits` only verifies the replace range of the newest cursor. If user has a cursor inside an existing import statement at the top of the file and another cursor further down, Zed fails to detect the overlap at the top of the file. When the user auto-completes the import statement ends up jumbled. This fix updates the completion logic to calculate the commit ranges for all active cursors and passes them to the LSP store. The overlap check now iterates over all commit ranges to ensure auto-imports are correctly discarded if they intersect with any of the user's multi-cursor edits. Release Notes: - Fixed an issue where accepting an autocomplete suggestion with multiple cursors could result in duplicated or jumbled text in import statements.
When accepting an autocomplete suggestion with multiple active cursors using
CMD+D, Zed applies the primary completion edit to all cursors. However, the overlap check for LSPadditionalTextEditsonly verifies the replace range of the newest cursor.If user has a cursor inside an existing import statement at the top of the file and another cursor further down, Zed fails to detect the overlap at the top of the file. When the user auto-completes the import statement ends up jumbled.
This fix updates the completion logic to calculate the commit ranges for all active cursors and passes them to the LSP store. The overlap check now iterates over all commit ranges to ensure auto-imports are correctly discarded if they intersect with any of the user's multi-cursor edits.
Closes #50314
Before
Screen.Recording.2026-02-27.at.21.14.12.mov
After
Screen.Recording.2026-02-27.at.21.16.10.mov
Before you mark this PR as ready for review, make sure that you have:
Release Notes: