Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down