This commit is contained in:
Jenia Dysin 2025-11-02 17:12:10 +02:00 committed by GitHub
commit d236e831b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2312,11 +2312,46 @@ impl<'a> Context<'a, '_> {
}
}
}
// Clicking on the left margin (gutter) should select the whole line.
let margin_rect = Rect {
left: inner.left,
top: inner.top,
right: inner.left + tb.margin_width(),
bottom: inner.bottom,
};
self.set_input_consumed();
return make_cursor_visible;
}
if margin_rect.contains(self.tui.mouse_down_position) {
// If the user is dragging the mouse after pressing in the margin,
// update the selection to span from the initial click line to the current mouse line.
if self.tui.mouse_is_drag {
// Ensure there's a selection anchor at the original cursor position.
if !tb.has_selection() {
tb.start_selection();
}
let drag_pos = Point { x: 0, y: pos.y };
tb.selection_update_visual(drag_pos);
tc.preferred_column = tb.cursor_visual_pos().x;
make_cursor_visible = true;
} else {
// Single click: either extend selection (Shift) or select the clicked line.
let click_pos = pos;
if self.input_mouse_modifiers.contains(kbmod::SHIFT) {
tb.selection_update_visual(click_pos);
} else {
tb.cursor_move_to_visual(click_pos);
tb.select_line();
}
tc.preferred_column = tb.cursor_visual_pos().x;
make_cursor_visible = true;
}
// Consume input once and return.
self.set_input_consumed();
return make_cursor_visible;
}
}
if !tc.has_focus {
return false;
}