1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Fix mouse mode bindings with multiple actions

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.

Regression was introduced in 1a143d11.
This commit is contained in:
EBADBEEF 2024-05-16 14:15:20 -07:00 committed by GitHub
parent 3cd35dfe7e
commit 38fed9a7c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -22,6 +22,8 @@ Notable changes to the `alacritty_terminal` crate are documented in its
- New window being treated as focused when it's not on Wayland
- IME preview blending into text below it
- Dynamic title disabled for new windows when initial one has title as CLI option
- While terminal in mouse mode, mouse bindings that used the shift modifier and
had multiple actions only performed the first action
## 0.13.2

View file

@ -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) {