From 4565e1aab5ee3e3f7c13e353ba93d9443477e877 Mon Sep 17 00:00:00 2001 From: bianca4444 Date: Fri, 24 Apr 2026 18:49:17 +0300 Subject: [PATCH] Select lines by clicking line number fix --- crates/edit/src/tui.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/edit/src/tui.rs b/crates/edit/src/tui.rs index 314cdc30cc6..4c9325ecef2 100644 --- a/crates/edit/src/tui.rs +++ b/crates/edit/src/tui.rs @@ -2257,6 +2257,12 @@ impl<'a> Context<'a, '_> { right: inner.right, bottom: inner.bottom, }; + let margin_rect = Rect { + left: inner.left, + top: inner.top, + right: inner.left + tb.margin_width(), + bottom: inner.bottom, + }; let pos = Point { x: mouse.x - inner.left - tb.margin_width() + tc.scroll_offset.x, y: mouse.y - inner.top + tc.scroll_offset.y, @@ -2343,8 +2349,25 @@ impl<'a> Context<'a, '_> { as CoordType; } } + } else if margin_rect.contains(self.tui.mouse_down_position) { + let clicked_y = mouse.y - inner.top + tc.scroll_offset.y; + + if self.tui.mouse_is_drag { + let drag_start_y = self.tui.mouse_down_position.y - inner.top + tc.scroll_offset.y; + let from_y = drag_start_y.min(clicked_y); + let to_y = drag_start_y.max(clicked_y); + + tb.cursor_move_to_visual(Point { x: 0, y: from_y }); + tb.selection_update_visual(Point { x: CoordType::MAX, y: to_y }); + } else { + tb.cursor_move_to_visual(Point { x: 0, y: clicked_y }); + tb.selection_update_visual(Point { x: CoordType::MAX, y: clicked_y }); } + tc.preferred_column = tb.cursor_visual_pos().x; + make_cursor_visible = true; + } + self.set_input_consumed(); return make_cursor_visible; }