Skip to content

Commit

Permalink
Fix selection copy without button release
Browse files Browse the repository at this point in the history
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 <ju.orth@gmail.com>
  • Loading branch information
mahkoh authored Apr 16, 2022
1 parent d5cad2a commit 9bbb296
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion alacritty/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> 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;
}
Expand Down
6 changes: 4 additions & 2 deletions alacritty/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,10 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
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) {
Expand Down

0 comments on commit 9bbb296

Please sign in to comment.