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 11d6e92cb5 (Show file location when querying bindings with bind, 2025-12-28)

Fixes #12798
This commit is contained in:
Johannes Altmanninger
2026-06-02 08:28:33 +08:00
parent 7acd489a06
commit f717c5e2a0
2 changed files with 5 additions and 3 deletions

View File

@@ -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);
}
}

View File

@@ -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 "