mirror of
https://github.com/microsoft/edit.git
synced 2025-12-23 07:07:25 +00:00
Merge 006f465d1b into 82cc84a610
This commit is contained in:
commit
d236e831b4
1 changed files with 38 additions and 3 deletions
41
src/tui.rs
41
src/tui.rs
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue