2014-09-19 06:45:07 +08:00
|
|
|
# vim: set filetype=expect:
|
|
|
|
spawn $fish
|
|
|
|
expect_prompt
|
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
# Test switching key bindings to vi mode.
|
|
|
|
# This should leave the mode in the appropriate state (i.e., insert mode).
|
2014-09-19 06:45:07 +08:00
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt
|
2015-12-24 07:24:45 +08:00
|
|
|
send -h "echo fail\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.510
|
|
|
|
send -h "ddiecho success\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt -re {\r\nsuccess\r\n} {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts "vi replace line success"
|
2014-09-19 06:45:07 +08:00
|
|
|
} -nounmatched -re {\r\nfail} {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts stderr "vi replace line fail"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'success'"
|
|
|
|
}
|
2015-12-24 07:24:45 +08:00
|
|
|
|
|
|
|
# Verify that a human can transpose words using \et (which is an emacs default
|
|
|
|
# binding but should be valid while in vi insert mode).
|
|
|
|
send "echo abc def\033"
|
|
|
|
# Fish should still be in vi "insert" mode after this delay.
|
|
|
|
sleep 0.400
|
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
|
|
|
puts "vi transpose words success"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts stderr "vi transpose words fail"
|
2014-09-19 06:45:07 +08:00
|
|
|
}
|
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
# Test replacing a single character.
|
|
|
|
send -h "echo TEXT\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.510
|
|
|
|
send -h "hhrAi\r"
|
2015-07-20 15:18:56 +08:00
|
|
|
expect_prompt -re {\r\nTAXT\r\n} {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts "vi mode replace success"
|
2015-07-20 15:18:56 +08:00
|
|
|
} -nounmatched -re {\r\nfail} {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts stderr "vi mode replace fail"
|
2015-07-20 15:18:56 +08:00
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'TAXT'"
|
|
|
|
}
|
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
# Switch back to regular (emacs mode) key bindings.
|
|
|
|
send -h "set -g fish_key_bindings fish_default_key_bindings\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt
|
2015-12-24 07:24:45 +08:00
|
|
|
send "echo success\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt -re {\r\nsuccess\r\n} {
|
2015-12-24 07:24:45 +08:00
|
|
|
puts "emacs success"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'success'"
|
|
|
|
} timeout {
|
|
|
|
set msg ""
|
|
|
|
append msg "Timeout after setting fish_key_bindings to fish_default_key_bindings\n" \
|
|
|
|
"\$fish_bind_mode is most likely still set to 'insert'"
|
|
|
|
abort $msg
|
|
|
|
}
|