Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
helix: Fix line select with empty first line (#48026)
Josh Robson Chasec47430debfae
diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rsindex 2c25ed267df..1b39faf1444 100644--- a/crates/vim/src/helix.rs+++ b/crates/vim/src/helix.rs@@ -714,7 +714,11 @@ impl Vim {// Check if cursor is on empty line by checking first characterlet line_start_offset = buffer_snapshot.point_to_offset(Point::new(start_row, 0));let first_char = buffer_snapshot.chars_at(line_start_offset).next();- let extra_line = if first_char == Some('\n') { 1 } else { 0 };+ let extra_line = if first_char == Some('\n') && selection.is_empty() {+ 1+ } else {+ 0+ };let end_row = current_end_row + count as u32 + extra_line;@@ -1335,7 +1339,9 @@ mod test {line oneˇline three- line four"},+ line four+ line five+ line six"},Mode::HelixNormal,);cx.simulate_keystrokes("x");@@ -1344,7 +1350,22 @@ mod test {line one«line three- ˇ»line four"},+ ˇ»line four+ line five+ line six"},+ Mode::HelixNormal,+ );++ // Another x should only select the next line+ cx.simulate_keystrokes("x");+ cx.assert_state(+ indoc! {"+ line one+ «+ line three+ line four+ ˇ»line five+ line six"},Mode::HelixNormal,);