Skip to content

Commit

Permalink
Fix mouse mode bindings with multiple actions
Browse files Browse the repository at this point in the history
The following config was broken:
```
  [mouse]
  bindings = [
  { mouse = "Right", mods = "Shift", action = "Copy"            },
  { mouse = "Right", mods = "Shift", action = "ClearSelection"  },
  ]
```

Only the first action was applied. Change to allow more than one exact
match in mouse mode with shift held, but keep the logic to not allow
fallback search if any exact match was found.

Fixes: 1a143d1 (Fix trigger of normal bindings in mouse mode)
  • Loading branch information
EBADBEEF committed May 7, 2024
1 parent 7077a5f commit bd34a3d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions alacritty/src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,17 +1004,18 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
let mouse_bindings = self.ctx.config().mouse_bindings().to_owned();

// If mouse mode is active, also look for bindings without shift.
let mut check_fallback = mouse_mode && mods.contains(ModifiersState::SHIFT);
let fallback_allowed = mouse_mode && mods.contains(ModifiersState::SHIFT);
let mut exact_match_found = false;

for binding in &mouse_bindings {
// Don't trigger normal bindings in mouse mode unless Shift is pressed.
if binding.is_triggered_by(mode, mods, &button) && (check_fallback || !mouse_mode) {
if binding.is_triggered_by(mode, mods, &button) && (fallback_allowed || !mouse_mode) {
binding.action.execute(&mut self.ctx);
check_fallback = false;
exact_match_found = true;
}
}

if check_fallback {
if fallback_allowed && !exact_match_found {
let fallback_mods = mods & !ModifiersState::SHIFT;
for binding in &mouse_bindings {
if binding.is_triggered_by(mode, fallback_mods, &button) {
Expand Down

0 comments on commit bd34a3d

Please sign in to comment.