vim: Handle exclusive-linewise edgecase correctly (#27786)

Before this change we didn't explicitly handle vim's exclusive-linewise
edgecase
(https://neovim.io/doc/user/motion.html#exclusive).

Instead we had hard-coded workarounds in a few places to make our tests
pass.
The most pernicious of these workarounds was that we represented a
visual line
selection as including the trailing newline (or leading newline for
files that
end with no newline), which other code had to undo to get back to what
the user
indended.

Closes #21440
Updates #6900

Release Notes:

- vim: Fixed `d]}` to not delete the closing brace
- vim: Fixed `d}` from the start of the line to not delete the paragraph
separator
- vim: Fixed `d}` from the middle of the line to not delete the final
newline
This commit is contained in:
Conrad Irwin 2025-03-31 10:36:20 -06:00 committed by GitHub
parent e1e8c1786e
commit fc269dfaf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 471 additions and 482 deletions

View file

@ -3,6 +3,7 @@ use gpui::{actions, Action};
use gpui::{Context, Window};
use language::{CharClassifier, CharKind};
use crate::motion::MotionKind;
use crate::{motion::Motion, state::Mode, Vim};
actions!(vim, [HelixNormalAfter, HelixDelete]);
@ -254,7 +255,7 @@ impl Vim {
});
});
vim.copy_selections_content(editor, false, window, cx);
vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx);
editor.insert("", window, cx);
});
}