mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 16:10:12 +08:00
b05e071238
fish_key_bindings may be set directly
or via fish_{default,vi}_key_bindings.
The latter use "set --no-event" to simplify their control
flow. This (24836f965
(Use set --no-event in the key binding
functions, 2023-01-10)) broke Vi mode cleanup, since Vi mode
uses a variable hook. Let's update this variable also when using
fish_{default,vi}_key_bindings. Another reason to keep this variable
in sync is to make the fish_key_bindings handlers working as expected.
19 lines
807 B
Fish
19 lines
807 B
Fish
function __fish_change_key_bindings --argument-names bindings
|
|
set -g __fish_active_key_bindings $bindings
|
|
# Allow the user to set the variable universally
|
|
set -l scope
|
|
set -q fish_key_bindings
|
|
or set scope -g
|
|
# We try to use `set --no-event`, but to avoid leaving the user without bindings
|
|
# if they run this with an older version we fall back on setting the variable
|
|
# with an event.
|
|
if ! set --no-event $scope fish_key_bindings $bindings 2>/dev/null
|
|
# This triggers the handler, which calls us again
|
|
set $scope fish_key_bindings $bindings
|
|
# unless the handler somehow doesn't exist, which would leave us without bindings.
|
|
# this happens in no-config mode.
|
|
functions -q __fish_reload_key_bindings
|
|
and return 1
|
|
end
|
|
end
|