diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-09-27 12:12:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 12:12:49 +0000 |
commit | 5e97fcbea4d763ab7059cce201d110ba9fb6c19f (patch) | |
tree | b634527c7bfcaca3c924a98c0448e7624630c116 /src/event.rs | |
parent | 593d7718d0d3e1e2071021d34178856079ac8bf7 (diff) | |
download | alacritty-5e97fcbea4d763ab7059cce201d110ba9fb6c19f.tar.gz alacritty-5e97fcbea4d763ab7059cce201d110ba9fb6c19f.zip |
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
Diffstat (limited to 'src/event.rs')
-rw-r--r-- | src/event.rs | 12 |
1 files changed, 7 insertions, 5 deletions
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) { @@ -131,6 +128,11 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } #[inline] + fn mouse(&self) -> &Mouse { + self.mouse + } + + #[inline] fn received_count(&mut self) -> &mut usize { &mut self.received_count } |