From 51128a3484049e5f9b9b74276222977d12554d76 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 31 Jan 2025 09:07:42 +0100 Subject: input: match unshifted key-bindings before shifted That is, try to match e.g. Control+shift+a, before trying to match Control+A. In most cases, order doesn't matter. There are however a couple of symbols where the layout consumes the shift-modifier, and the generated symbol is the same in both the shifted and unshifted form. One such example is backspace. Before this patch, key-bindings with shift-backspace would be ignored, if there were another key-binding with backspace. So, for example, if we had one key-binding with Control+Backspace, and another with Control+Shift+Backspace, the latter would never trigger, as we would always match the first one. By checking for unshifted matches first, we ensure Control+Shift+Backspace does match. --- search.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'search.c') diff --git a/search.c b/search.c index 75f12b4a..20990c87 100644 --- a/search.c +++ b/search.c @@ -1392,23 +1392,6 @@ search_input(struct seat *seat, struct terminal *term, * Key bindings */ - /* Match translated symbol */ - tll_foreach(bindings->search, it) { - const struct key_binding *bind = &it->item; - - if (bind->k.sym == sym && - bind->mods == (mods & ~consumed)) { - - if (execute_binding(seat, term, bind, serial, - &update_search_result, &search_direction, - &redraw)) - { - goto update_search; - } - return; - } - } - /* Match untranslated symbols */ tll_foreach(bindings->search, it) { const struct key_binding *bind = &it->item; @@ -1429,6 +1412,23 @@ search_input(struct seat *seat, struct terminal *term, } } + /* Match translated symbol */ + tll_foreach(bindings->search, it) { + const struct key_binding *bind = &it->item; + + if (bind->k.sym == sym && + bind->mods == (mods & ~consumed)) { + + if (execute_binding(seat, term, bind, serial, + &update_search_result, &search_direction, + &redraw)) + { + goto update_search; + } + return; + } + } + /* Match raw key code */ tll_foreach(bindings->search, it) { const struct key_binding *bind = &it->item; -- cgit v1.3