From 5e97fcbea4d763ab7059cce201d110ba9fb6c19f Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 27 Sep 2018 12:12:49 +0000 Subject: Fix selection start point lagging behind cursor Since the mouse start position has been the first movement event after the mouse button was held down, there have been some issues with the start point lagging behind the cursor because movement events were not reported from the initial position but there was a gap until movement starts reporting. To fix this whenever the mouse button is pressed, the position and cell side is stored on the `Mouse` struct. Because of this it does not matter anymore if the movement events are all reported and we can just start a selection using the stored position/side whenever there currently is no selection present. This fixes #1366 --- src/event.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index da63d5fd..9db0680d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -82,17 +82,14 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } fn update_selection(&mut self, point: Point, side: Side) { - self.terminal.dirty = true; let point = self.terminal.visible_to_buffer(point); // Update selection if one exists - if let Some(ref mut selection) = *self.terminal.selection_mut() { + if let Some(ref mut selection) = self.terminal.selection_mut() { selection.update(point, side); - return; } - // Otherwise, start a regular selection - *self.terminal.selection_mut() = Some(Selection::simple(point, side)); + self.terminal.dirty = true; } fn simple_selection(&mut self, point: Point, side: Side) { @@ -130,6 +127,11 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.mouse } + #[inline] + fn mouse(&self) -> &Mouse { + self.mouse + } + #[inline] fn received_count(&mut self) -> &mut usize { &mut self.received_count -- cgit