aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/input
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2025-05-21 00:51:48 +0000
committerGitHub <noreply@github.com>2025-05-21 00:51:48 +0000
commit4db89382f657cff9092fdfec671fc440a44af841 (patch)
treed334c28f8149d45eda88a77230abfde134f4bb2c /alacritty/src/input
parent71feeeeccc422d8092bda56b0d38693290f7585f (diff)
downloadr-alacritty-4db89382f657cff9092fdfec671fc440a44af841.tar.gz
r-alacritty-4db89382f657cff9092fdfec671fc440a44af841.tar.bz2
r-alacritty-4db89382f657cff9092fdfec671fc440a44af841.zip
Fix hint binding IPC overrides
This fixes an issue where changes made to the bindings of a hint through IPC were completely ignored, since the hint key bindings were only generated on config load without regeneration on IPC config override. While it would be possible to just filter out remove hint key bindings based on their action and then repopulate them on IPC config reload, this solution would be quite hacky. To have a better distinction between traditional and hint key bindings, the two have been entirely separated and hint bindings are just converted to key bindings on demand. This allows easily replacing the entire hint array without any post-processing, making it simpler to maintain for future changes. Closes #8568.
Diffstat (limited to 'alacritty/src/input')
-rw-r--r--alacritty/src/input/keyboard.rs32
1 files changed, 27 insertions, 5 deletions
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs
index 113472c4..24d1abad 100644
--- a/alacritty/src/input/keyboard.rs
+++ b/alacritty/src/input/keyboard.rs
@@ -11,7 +11,7 @@ use alacritty_terminal::event::EventListener;
use alacritty_terminal::term::TermMode;
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
-use crate::config::{Action, BindingKey, BindingMode};
+use crate::config::{Action, BindingKey, BindingMode, KeyBinding};
use crate::event::TYPING_SEARCH_DELAY;
use crate::input::{ActionContext, Execute, Processor};
use crate::scheduler::{TimerId, Topic};
@@ -203,9 +203,8 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
key.logical_key.clone()
};
- for i in 0..self.ctx.config().key_bindings().len() {
- let binding = &self.ctx.config().key_bindings()[i];
-
+ // Get the action of a key binding.
+ let mut binding_action = |binding: &KeyBinding| {
let key = match (&binding.trigger, &logical_key) {
(BindingKey::Scancode(_), _) => BindingKey::Scancode(key.physical_key),
(_, code) => {
@@ -218,7 +217,30 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
*suppress_chars.get_or_insert(true) &= binding.action != Action::ReceiveChar;
// Binding was triggered; run the action.
- binding.action.clone().execute(&mut self.ctx);
+ Some(binding.action.clone())
+ } else {
+ None
+ }
+ };
+
+ // Trigger matching key bindings.
+ for i in 0..self.ctx.config().key_bindings().len() {
+ let binding = &self.ctx.config().key_bindings()[i];
+ if let Some(action) = binding_action(binding) {
+ action.execute(&mut self.ctx);
+ }
+ }
+
+ // Trigger key bindings for hints.
+ for i in 0..self.ctx.config().hints.enabled.len() {
+ let hint = &self.ctx.config().hints.enabled[i];
+ let binding = match hint.binding.as_ref() {
+ Some(binding) => binding.key_binding(hint),
+ None => continue,
+ };
+
+ if let Some(action) = binding_action(binding) {
+ action.execute(&mut self.ctx);
}
}