From f717c5e2a091aa403581d2fa6ecdaea0d9d45540 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 2 Jun 2026 08:28:33 +0800 Subject: [PATCH] Fix "bind -M somemode" crash for empty bind modes This loop iterates over all bindings and crashes if a mode filter argument is given for a mode that has no binding. Fix this by continuing the loop earlier. Fixes 11d6e92cb5a (Show file location when querying bindings with bind, 2025-12-28) Fixes #12798 --- src/builtins/bind.rs | 6 +++--- tests/checks/bind.fish | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/builtins/bind.rs b/src/builtins/bind.rs index 6275d4b53..7e5f27df2 100644 --- a/src/builtins/bind.rs +++ b/src/builtins/bind.rs @@ -213,6 +213,9 @@ fn list( let mut cur_file = None; for binding in lst { + if bind_mode.is_some_and(|m| m != binding.mode) { + continue; + } let mut out = WString::new(); let definition_file = &self.input_mappings.get(&binding.seq, bind_mode, user)[0].definition_file; @@ -233,9 +236,6 @@ fn list( cur_file = Some(def_file); } } - if bind_mode.is_some_and(|m| m != binding.mode) { - continue; - } self.list_one(&binding.seq, Some(&binding.mode), user, parser, streams); } } diff --git a/tests/checks/bind.fish b/tests/checks/bind.fish index 7ca2106c8..2028fbd6c 100644 --- a/tests/checks/bind.fish +++ b/tests/checks/bind.fish @@ -3,6 +3,8 @@ set -l fish (status fish-path) +bind -M insert + set -l tmpdir (mktemp -d) for bindings in true fish_default_key_bindings fish_vi_key_bindings $fish -c "