From 9bbb296d1dc4f72e845695f22e903bcc1d66d5a3 Mon Sep 17 00:00:00 2001 From: mahkoh Date: Sat, 16 Apr 2022 20:39:26 +0200 Subject: [PATCH] Fix selection copy without button release To prevent the current selection clipboard from being overwritten right before pasting, text is no longer copied solely because the user scrolled the scrollback buffer. The selection also isn't copied when a mouse button other than LMB/RMB are released, since these are the only ones capable of modifying the selection range. This should prevent issues where the selection of the user gets unexpectedly overwritten, especially in scenarios where the user is currently in the process of pasting something into Alacritty. Signed-off-by: Julian Orth --- CHANGELOG.md | 1 + alacritty/src/event.rs | 1 - alacritty/src/input.rs | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c43909c7..4439f9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Failure when running on 10-bit color system - The colors being slightly different when using srgb displays on macOS - Vi cursor blinking not reset when navigating in search +- Scrolling and middle-clicking modifying the primary selection ## 0.10.1 diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index d32fd6e5..1db6e450 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -233,7 +233,6 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon let point = self.mouse.point(&self.size_info(), display_offset); self.update_selection(point, self.mouse.cell_side); } - self.copy_selection(ClipboardType::Selection); *self.dirty = true; } diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 16649327..0f389851 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -614,8 +614,10 @@ impl> Processor { let timer_id = TimerId::new(Topic::SelectionScrolling, self.ctx.window().id()); self.ctx.scheduler_mut().unschedule(timer_id); - // Copy selection on release, to prevent flooding the display server. - self.ctx.copy_selection(ClipboardType::Selection); + if let MouseButton::Left | MouseButton::Right = button { + // Copy selection on release, to prevent flooding the display server. + self.ctx.copy_selection(ClipboardType::Selection); + } } pub fn mouse_wheel_input(&mut self, delta: MouseScrollDelta, phase: TouchPhase) {