From 7bd3b8991ce290e981d39d608a91bdc174b26f5d Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sun, 29 Dec 2024 00:47:47 +0300 Subject: Don't switch semantic/line selection when control is pressed Changing block selection to regular semantic one doesn't feel intuitive, thus don't switch to it when user has control pressed. --- alacritty/src/event.rs | 12 ++++-------- alacritty/src/input/mod.rs | 9 +++++---- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 79f31eef..2ac6279d 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -1183,17 +1183,13 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon /// Expand the selection to the current mouse cursor position. #[inline] fn expand_selection(&mut self) { + let control = self.modifiers().state().control_key(); let selection_type = match self.mouse().click_state { - ClickState::Click => { - if self.modifiers().state().control_key() { - SelectionType::Block - } else { - SelectionType::Simple - } - }, + ClickState::None => return, + _ if control => SelectionType::Block, + ClickState::Click => SelectionType::Simple, ClickState::DoubleClick => SelectionType::Semantic, ClickState::TripleClick => SelectionType::Lines, - ClickState::None => return, }; // Load mouse point, treating message bar and padding as the closest cell. diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs index 1c9d6008..60a50529 100644 --- a/alacritty/src/input/mod.rs +++ b/alacritty/src/input/mod.rs @@ -637,6 +637,7 @@ impl> Processor { /// Handle left click selection and vi mode cursor movement. fn on_left_click(&mut self, point: Point) { let side = self.ctx.mouse().cell_side; + let control = self.ctx.modifiers().state().control_key(); match self.ctx.mouse().click_state { ClickState::Click => { @@ -646,21 +647,21 @@ impl> Processor { self.ctx.clear_selection(); // Start new empty selection. - if self.ctx.modifiers().state().control_key() { + if control { self.ctx.start_selection(SelectionType::Block, point, side); } else { self.ctx.start_selection(SelectionType::Simple, point, side); } }, - ClickState::DoubleClick => { + ClickState::DoubleClick if !control => { self.ctx.mouse_mut().block_hint_launcher = true; self.ctx.start_selection(SelectionType::Semantic, point, side); }, - ClickState::TripleClick => { + ClickState::TripleClick if !control => { self.ctx.mouse_mut().block_hint_launcher = true; self.ctx.start_selection(SelectionType::Lines, point, side); }, - ClickState::None => (), + _ => (), }; // Move vi mode cursor to mouse click position. -- cgit