diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2025-01-27 09:51:03 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-01-27 11:31:40 +0000 |
| commit | 8d6f0d0583a1cb7c245ff54ec472a03ebcdb6949 (patch) | |
| tree | b532ad7ac6db0738c01ce6ddb8e646f121441d9d /search.c | |
| parent | forgejo: application -> application(s) (diff) | |
key-bindings: try all bindings in translated mode before matching untranslated, and then finally raw
When trying to match key bindings, we do three types of matching:
* Match the _translated_ symbol (e.g. Control+C)
* Match the _untranslated_ symbol (e.g. Control+Shift+c)
* Match raw keyboard codes
This was done for *each* key binding. This meant we sometimes matched
a keybinding in raw mode, even though there was a
translated/untranslated binding that would match it too. All depending
on the internal order of the key binding list.
This patch changes it, so that we first try all bindings in translated
mode, then all bindings in untranslated mode, and finally all bindings
in raw mode.
Closes #1929
Diffstat (limited to 'search.c')
| -rw-r--r-- | search.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1388,11 +1388,14 @@ search_input(struct seat *seat, struct terminal *term, bool update_search_result = false; bool redraw = false; - /* Key bindings */ + /* + * Key bindings + */ + + /* Match translated symbol */ tll_foreach(bindings->search, it) { const struct key_binding *bind = &it->item; - /* Match translated symbol */ if (bind->k.sym == sym && bind->mods == (mods & ~consumed)) { @@ -1404,11 +1407,15 @@ search_input(struct seat *seat, struct terminal *term, } return; } + } + + /* Match untranslated symbols */ + tll_foreach(bindings->search, it) { + const struct key_binding *bind = &it->item; if (bind->mods != mods) continue; - /* Match untranslated symbols */ for (size_t i = 0; i < raw_count; i++) { if (bind->k.sym == raw_syms[i]) { if (execute_binding(seat, term, bind, serial, @@ -1420,8 +1427,15 @@ search_input(struct seat *seat, struct terminal *term, return; } } + } + + /* Match raw key code */ + tll_foreach(bindings->search, it) { + const struct key_binding *bind = &it->item; + + if (bind->mods != mods) + continue; - /* Match raw key code */ tll_foreach(bind->k.key_codes, code) { if (code->item == key) { if (execute_binding(seat, term, bind, serial, |
