From cff097197f0e002636f982c70278dedf057256e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 8 Feb 2022 21:21:17 +0100 Subject: [PATCH] config: do key binding collision handling in overrides This ensures we detect, and handle, collisions also for key-bindings specified as overrides. --- CHANGELOG.md | 2 ++ config.c | 35 +++++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab8d4b81..a385e3ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ * Exit code being 0 when a foot server with no open windows terminate due to e.g. a Wayland connection failure (https://codeberg.org/dnkl/foot/issues/943). +* Key binding collisions not detected for bindings specified as option + overrides on the command line. ### Security diff --git a/config.c b/config.c index 99083130..f50ee685 100644 --- a/config.c +++ b/config.c @@ -3053,25 +3053,12 @@ config_load(struct config *conf, const char *conf_path, goto out; } - ret = parse_config_file(f, conf, conf_file.path, errors_are_fatal) && - config_override_apply(conf, overrides, errors_are_fatal); - - if (ret && - (!resolve_key_binding_collisions( - conf, section_info[SECTION_KEY_BINDINGS].name, - binding_action_map, &conf->bindings.key, KEY_BINDING) || - !resolve_key_binding_collisions( - conf, section_info[SECTION_SEARCH_BINDINGS].name, - search_binding_action_map, &conf->bindings.search, KEY_BINDING) || - !resolve_key_binding_collisions( - conf, section_info[SECTION_URL_BINDINGS].name, - url_binding_action_map, &conf->bindings.url, KEY_BINDING) || - !resolve_key_binding_collisions( - conf, section_info[SECTION_MOUSE_BINDINGS].name, - binding_action_map, &conf->bindings.mouse, MOUSE_BINDING))) + if (!parse_config_file(f, conf, conf_file.path, errors_are_fatal) || + !config_override_apply(conf, overrides, errors_are_fatal)) { ret = !errors_are_fatal; - } + } else + ret = true; fclose(f); @@ -3163,7 +3150,19 @@ config_override_apply(struct config *conf, config_override_t *overrides, conf->csd.border_width = max( min_csd_border_width, conf->csd.border_width_visible); - return true; + return + resolve_key_binding_collisions( + conf, section_info[SECTION_KEY_BINDINGS].name, + binding_action_map, &conf->bindings.key, KEY_BINDING) && + resolve_key_binding_collisions( + conf, section_info[SECTION_SEARCH_BINDINGS].name, + search_binding_action_map, &conf->bindings.search, KEY_BINDING) && + resolve_key_binding_collisions( + conf, section_info[SECTION_URL_BINDINGS].name, + url_binding_action_map, &conf->bindings.url, KEY_BINDING) && + resolve_key_binding_collisions( + conf, section_info[SECTION_MOUSE_BINDINGS].name, + binding_action_map, &conf->bindings.mouse, MOUSE_BINDING); } static void NOINLINE