aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-07-20 00:18:56 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-07-20 00:29:08 -0700
commit2109af0987ce6daab95daa053199ab4f7cafb970 (patch)
tree550ed2b38de1ca897c86b7a8a1fd3c7344f1dcb0
parent68bbe13d23227585f038a73fd96559b758a14948 (diff)
Implement lowercase-r replace in fish_vi_mode
Fixes #1595
-rw-r--r--share/functions/fish_mode_prompt.fish3
-rw-r--r--share/functions/fish_vi_key_bindings.fish6
-rw-r--r--tests/bind.expect10
-rw-r--r--tests/bind.expect.out1
4 files changed, 20 insertions, 0 deletions
diff --git a/share/functions/fish_mode_prompt.fish b/share/functions/fish_mode_prompt.fish
index 30521679..e9b49e5b 100644
--- a/share/functions/fish_mode_prompt.fish
+++ b/share/functions/fish_mode_prompt.fish
@@ -9,6 +9,9 @@ function fish_mode_prompt --description "Displays the current mode"
case insert
set_color --bold --background green white
echo '[I]'
+ case replace-one
+ set_color --bold --background green white
+ echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish
index aa6dda6f..54cc5b31 100644
--- a/share/functions/fish_vi_key_bindings.fish
+++ b/share/functions/fish_vi_key_bindings.fish
@@ -198,7 +198,13 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
bind -M insert \ef forward-word
+ #
+ # Lowercase r, enters replace-one mode
+ #
+ bind -m replace-one r force-repaint
+ bind -M replace-one -m default '' delete-char self-insert backward-char force-repaint
+ bind -M replace-one -m default \e cancel force-repaint
#
# visual mode
diff --git a/tests/bind.expect b/tests/bind.expect
index 91585c96..9df5b37c 100644
--- a/tests/bind.expect
+++ b/tests/bind.expect
@@ -27,6 +27,16 @@ expect_prompt -re {\r\nsuccess\r\n} {
puts stderr "Couldn't find expected output 'success'"
}
+# Test lowercase-r replace
+send_line "\033ddiecho TEXT\033hhrAi"
+expect_prompt -re {\r\nTAXT\r\n} {
+ puts "replace success"
+} -nounmatched -re {\r\nfail} {
+ puts stderr "replace fail"
+} unmatched {
+ puts stderr "Couldn't find expected output 'TAXT'"
+}
+
# still in insert mode, switch back to regular key bindings
send_line "set -g fish_key_bindings fish_default_key_bindings"
expect_prompt
diff --git a/tests/bind.expect.out b/tests/bind.expect.out
index a670195e..7f883abd 100644
--- a/tests/bind.expect.out
+++ b/tests/bind.expect.out
@@ -1,3 +1,4 @@
success
success
+replace success
success