Vim/Helix: Prevent undo grouping when any LSP completion#53980
Conversation
fda61bf to
0528357
Compare
|
Unassigned myself as apparently do not understand Vim specific related to all this. I have assumed we need a generic fix like #52699 or similar and got quite confused on the current impl. |
Yeah.... |
|
Maybe I need some help here. After digging deeper, the core issue is very specific to Vim/Helix mode: Vim tracks an entire Insert mode session as a single undo group via While it might be tempting to add metadata to the generic |
5108974 to
f7fdf28
Compare
|
Maybe explicitly calls zed/crates/project/src/lsp_store.rs Lines 7014 to 7015 in ff8fa05 we can actually solve this elegantly without adding any Vim-specific boolean flags ( |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
This definitely looks like a proper direction!
2 small questions I have left:
- pending LSP completion edits are the additional text edits, if I understand the issue right?
If so, then can we move the fix under if let Some checks in
Or do you think this fix should apply to all, "synchronous" also, edits?
- The only fix-related comment I've found is
zed/crates/language/src/buffer.rs
Lines 2479 to 2481 in d4f06ee
and that does not explain much what happens here.
Can we add a small comment on why this is needed and how the rest of the code interacts with it?
If it helps, a good example of such comment is a few lines above: https://github.com/zed-industries/zed/blob/d4f06ee3740b0da1bd55476a5ff19d7c2ac1e57f/crates/editor/src/editor.rs#L6953-L6954
Yes — the pending LSP completion edits are the additional text edits. Regarding your second question: I intentionally placed the fix (
Lines 1941 to 1949 in 8a8293b
Here is the video about their behaviour. Sorry for that I do not have neovim locally, so I asked my friend to have a test in his machine, but the video have a bit blurry. Neovimneovim.mp4Helixhelix.mp4Does this solve your concerns? |
41ea0e0 to
e9b9a01
Compare
|
Sorry for the delay—I've been under academic pressure |
Self-Review Checklist:
Summary
Prevent undo grouping when an LSP completion includes extra edits so that the completion and its extra edits are applied and reverted atomically.
Problem
When applying an LSP completion that also applies extra edits, the editor may merge that completion into the surrounding undo group or split the transaction while waiting for edits, causing undo to leave the buffer in an inconsistent state.
Solution
Closes #ISSUE
Release Notes: