Fix live right-click expansion

While the commit 43c0ad6ea9 introduced
right click as a way to expand the active selection, it did not allow
for holding right click to continuously do so.

This commit remedies that problem by allowing live expansion with while
holding the right mouse button.
This commit is contained in:
Christian Duerr 2020-06-24 08:29:07 +00:00 committed by GitHub
parent 5eb0792c90
commit f0775b3c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -361,7 +361,9 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
self.ctx.window_mut().set_mouse_cursor(mouse_state.into());
let last_term_line = self.ctx.terminal().grid().num_lines() - 1;
if lmb_pressed && (self.ctx.modifiers().shift() || !self.ctx.mouse_mode()) {
if (lmb_pressed || self.ctx.mouse().right_button_state == ElementState::Pressed)
&& (self.ctx.modifiers().shift() || !self.ctx.mouse_mode())
{
// Treat motion over message bar like motion over the last line.
let line = min(point.line, last_term_line);
@ -558,6 +560,11 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
selection.ty = selection_type;
self.ctx.update_selection(point, cell_side);
// Move vi mode cursor to mouse click position.
if self.ctx.terminal().mode().contains(TermMode::VI) {
self.ctx.terminal_mut().vi_mode_cursor.point = point;
}
}
/// Handle left click selection and vi mode cursor movement.
@ -589,9 +596,8 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
ClickState::None => (),
};
// Move vi mode cursor to mouse position.
// Move vi mode cursor to mouse click position.
if self.ctx.terminal().mode().contains(TermMode::VI) {
// Update Vi mode cursor position on click.
self.ctx.terminal_mut().vi_mode_cursor.point = point;
}
}