From 500b696ca8ed61c42f5954b10f1294e875d792ae Mon Sep 17 00:00:00 2001 From: Pavel Roskin <1317472+proski@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:04:32 -0700 Subject: Prefer exact matches for bindings in mouse mode Only consider bindings without Shift if there are no actions defined for the actual mouse event. Closes #7292. --- alacritty/src/input.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 428cda0d..f1a8e7d7 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -1003,17 +1003,24 @@ impl> Processor { let mode = BindingMode::new(self.ctx.terminal().mode(), self.ctx.search_active()); let mouse_mode = self.ctx.mouse_mode(); let mods = self.ctx.modifiers().state(); + let mouse_bindings = self.ctx.config().mouse_bindings().to_owned(); - for i in 0..self.ctx.config().mouse_bindings().len() { - let mut binding = self.ctx.config().mouse_bindings()[i].clone(); - - // Require shift for all modifiers when mouse mode is active. - if mouse_mode { - binding.mods |= ModifiersState::SHIFT; - } + // If mouse mode is active, also look for bindings without shift. + let mut check_fallback = mouse_mode && mods.contains(ModifiersState::SHIFT); + for binding in &mouse_bindings { if binding.is_triggered_by(mode, mods, &button) { binding.action.execute(&mut self.ctx); + check_fallback = false; + } + } + + if check_fallback { + let fallback_mods = mods & !ModifiersState::SHIFT; + for binding in &mouse_bindings { + if binding.is_triggered_by(mode, fallback_mods, &button) { + binding.action.execute(&mut self.ctx); + } } } } -- cgit