From 352a554c748feb88b3f5a36a152a7e0863b3bc18 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 20 Oct 2023 11:30:32 -0600 Subject: [PATCH] Fix bug in vim visual block mode --- crates/gpui/src/text_layout.rs | 6 +----- crates/vim/src/visual.rs | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/gpui/src/text_layout.rs b/crates/gpui/src/text_layout.rs index 0d0b8bebb50f145f8ae68978b4ad15088f1e3f37..7fb87b10df2ce3baf822fbe5a6fddb4955e5f134 100644 --- a/crates/gpui/src/text_layout.rs +++ b/crates/gpui/src/text_layout.rs @@ -302,11 +302,7 @@ impl Line { prev_x = glyph.position.x(); } } - if self.width() - x < x - prev_x { - prev_index + 1 - } else { - prev_index - } + prev_index } pub fn paint( diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 05118e22f8caf5f58a084bbd3eae88550c3959fd..0e108251e2e75ac34f7543c4c028c602ab1f97a3 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -156,7 +156,7 @@ pub fn visual_block_motion( }; let mut goal = SelectionGoal::HorizontalRange { start, end }; - let was_reversed = head_x > tail_x; + let was_reversed = tail_x > head_x; if !was_reversed && !preserve_goal { head = movement::saturating_left(map, head); } @@ -184,8 +184,6 @@ pub fn visual_block_motion( let positions = if is_reversed { head_x..tail_x - } else if head_x == tail_x { - map.x_for_point(movement::saturating_left(map, tail), &text_layout_details)..head_x } else { tail_x..head_x };