vim: Further improve ~ handling

Now works with Visual{line} mode, collapses selections like nvim,
and doesn't fall off the end of the line.
This commit is contained in:
Conrad Irwin 2023-07-03 23:52:11 -06:00
parent e36d5f41c8
commit 0d18b72cf8
3 changed files with 99 additions and 31 deletions

View file

@ -171,15 +171,25 @@ impl NeovimConnection {
.await
.expect("Could not get neovim window");
if !selection.is_empty() {
panic!("Setting neovim state with non empty selection not yet supported");
}
let cursor = selection.start;
nvim_window
.set_cursor((cursor.row as i64 + 1, cursor.column as i64))
.await
.expect("Could not set nvim cursor position");
if !selection.is_empty() {
self.nvim
.input("v")
.await
.expect("could not enter visual mode");
let cursor = selection.end;
nvim_window
.set_cursor((cursor.row as i64 + 1, cursor.column as i64))
.await
.expect("Could not set nvim cursor position");
}
if let Some(NeovimData::Get { mode, state }) = self.data.back() {
if *mode == Some(Mode::Normal) && *state == marked_text {
return;