Add a VisualBlock mode

Instead of trying to extend the Mode::Visual special case, just split
out into three different modes.
This commit is contained in:
Conrad Irwin 2023-08-15 08:48:01 -06:00
parent 404b1aa65a
commit 1cc0798aea
16 changed files with 94 additions and 90 deletions

View file

@ -116,7 +116,7 @@ impl<'a> NeovimBackedTestContext<'a> {
pub async fn set_shared_state(&mut self, marked_text: &str) -> ContextHandle {
let mode = if marked_text.contains("»") {
Mode::Visual { line: false }
Mode::Visual
} else {
Mode::Normal
};

View file

@ -261,8 +261,9 @@ impl NeovimConnection {
let mode = match nvim_mode_text.as_ref() {
"i" => Some(Mode::Insert),
"n" => Some(Mode::Normal),
"v" => Some(Mode::Visual { line: false }),
"V" => Some(Mode::Visual { line: true }),
"v" => Some(Mode::Visual),
"V" => Some(Mode::VisualLine),
"CTRL-V" => Some(Mode::VisualBlock),
_ => None,
};
@ -270,7 +271,7 @@ impl NeovimConnection {
// Zed uses the index of the positions between the characters, so we need
// to add one to the end in visual mode.
match mode {
Some(Mode::Visual { .. }) => {
Some(Mode::Visual) | Some(Mode::VisualLine) | Some(Mode::VisualBlock) => {
if selection_col > cursor_col {
let selection_line_length =
self.read_position("echo strlen(getline(line('v')))").await;