From 54319435f43add1c5001e26ae9b505946f64950d Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Thu, 28 Apr 2016 20:53:09 -0700 Subject: [PATCH] clarify fish_vi_mode deprecation warning Also, correct the Vi mode default escape timeout. I intended it to be 100 ms in my previous change but it ended up 10 ms which is far too short. A 10 ms delay will continue to cause problems for people running fish inside `screen`, `tmux`, or over high latency connections. Cherry-picked from 3e24ae80b3739ded7d4066349fc87d13f2b70727 --- share/functions/fish_vi_key_bindings.fish | 17 +++++++++++------ share/functions/fish_vi_mode.fish | 10 ++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 2518ab74c..edff29f88 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -1,10 +1,15 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' - # The default escape timeout is 300ms. But for users of Vi bindings that can - # be slightly annoying when trying to switch to Vi "normal" mode. Too, - # vi-mode users are unlikely to use escape-as-meta. So set a much shorter - # timeout in this case. - set -q fish_escape_delay_ms - or set -g fish_escape_delay_ms 10 + if test "$fish_key_bindings" != "fish_vi_key_bindings" + # Allow the user to set the variable universally + set -q fish_key_bindings; or set -g fish_key_bindings + set fish_key_bindings fish_vi_key_bindings # This triggers the handler, which calls us again and ensures the user_key_bindings are executed + return + end + + # The default escape timeout is 300ms. But for users of Vi bindings that can be slightly + # annoying when trying to switch to Vi "normal" mode. So set a shorter timeout in this case + # unless the user has explicitly set the delay. + set -q fish_escape_delay_ms; or set -g fish_escape_delay_ms 100 set -l init_mode insert set -l eol_keys \$ g\$ \e\[F diff --git a/share/functions/fish_vi_mode.fish b/share/functions/fish_vi_mode.fish index b4fbe63a7..4b54dd00f 100644 --- a/share/functions/fish_vi_mode.fish +++ b/share/functions/fish_vi_mode.fish @@ -1,8 +1,6 @@ function fish_vi_mode - # Set the __fish_vi_mode variable - # This triggers fish_mode_prompt to output the mode indicator - set -g __fish_vi_mode 1 - - # Turn on vi keybindings - set -g fish_key_bindings fish_vi_key_bindings + echo 'The `fish_vi_mode` function is deprecated.' >&2 + echo 'Please switch to calling `fish_vi_key_bindings`.' >&2 + # Turn on vi keybindings + set -g fish_key_bindings fish_vi_key_bindings end