2014-09-18 22:45:07 +00:00
|
|
|
# vim: set filetype=expect:
|
|
|
|
spawn $fish
|
|
|
|
expect_prompt
|
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
# Fish should start in default-mode (i.e., emacs) bindings. The default escape
|
2019-02-07 11:08:24 +00:00
|
|
|
# timeout is 30ms.
|
2014-09-18 22:45:07 +00:00
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
|
|
|
send "echo abc def"
|
|
|
|
send "\033t\r"
|
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: no delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: no delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > 0 and < the escape timeout. This should transpose
|
|
|
|
# the words.
|
|
|
|
send "echo ghi jkl"
|
|
|
|
send "\033"
|
2019-02-07 11:08:24 +00:00
|
|
|
sleep 0.010
|
2016-02-01 01:37:51 +00:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\njkl ghi\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: short delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: short delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
|
|
|
send "echo mno pqr"
|
|
|
|
send "\033"
|
2019-02-07 11:08:24 +00:00
|
|
|
sleep 0.200
|
2016-02-01 01:37:51 +00:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\nmno pqrt\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: long delay"
|
|
|
|
}
|
2014-09-18 22:45:07 +00:00
|
|
|
|
2017-03-16 17:35:44 +00:00
|
|
|
# Now test that exactly the expected bind modes are defined
|
|
|
|
send "bind --list-modes\r"
|
|
|
|
expect_prompt -re {\r\ndefault\r\npaste} {
|
|
|
|
puts "emacs bind modes"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Unexpected bind modes"
|
|
|
|
}
|
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
# Test vi key bindings.
|
|
|
|
# This should leave vi mode in the insert state.
|
2017-12-21 23:44:18 +00:00
|
|
|
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
2014-09-18 22:45:07 +00:00
|
|
|
expect_prompt
|
2016-01-24 02:24:54 +00:00
|
|
|
|
2016-02-05 00:32:25 +00:00
|
|
|
# Go through a prompt cycle to let fish catch up, it may be slow due to ASAN
|
2016-01-24 02:24:54 +00:00
|
|
|
send "echo success: default escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "prime vi mode, default timeout"
|
2014-09-18 22:45:07 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "prime vi mode, default timeout"
|
2014-09-18 22:45:07 +00:00
|
|
|
}
|
2016-01-24 02:24:54 +00:00
|
|
|
|
2016-01-15 05:46:53 +00:00
|
|
|
send "echo fail: default escape timeout"
|
|
|
|
send "\033"
|
2016-02-11 02:09:55 +00:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode. The delay is
|
|
|
|
# longer than strictly necessary to let fish catch up as it may be slow due to
|
|
|
|
# ASAN.
|
2016-04-29 04:12:58 +00:00
|
|
|
sleep 0.150
|
2016-01-15 05:46:53 +00:00
|
|
|
send "ddi"
|
|
|
|
send "echo success: default escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "vi replace line, default timeout: long delay"
|
2014-09-18 22:45:07 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "vi replace line, default timeout: long delay"
|
2014-09-18 22:45:07 +00:00
|
|
|
}
|
2015-12-23 23:24:45 +00:00
|
|
|
|
|
|
|
# Test replacing a single character.
|
2016-01-15 05:46:53 +00:00
|
|
|
send "echo TEXT"
|
|
|
|
send "\033"
|
2015-12-23 23:24:45 +00:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2016-04-29 04:12:58 +00:00
|
|
|
sleep 0.150
|
2016-01-15 05:46:53 +00:00
|
|
|
send "hhrAi\r"
|
2015-07-20 07:18:56 +00:00
|
|
|
expect_prompt -re {\r\nTAXT\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "vi mode replace char, default timeout: long delay"
|
2015-07-20 07:18:56 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "vi mode replace char, default timeout: long delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-30 20:28:43 +00:00
|
|
|
# Test deleting characters with 'x'.
|
|
|
|
send "echo MORE-TEXT"
|
|
|
|
send "\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2018-01-16 17:11:46 +00:00
|
|
|
sleep 0.250
|
2016-11-30 20:28:43 +00:00
|
|
|
send "xxxxx\r"
|
|
|
|
expect_prompt -re {\r\nMORE\r\n} {
|
|
|
|
puts "vi mode delete char, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "vi mode delete char, default timeout: long delay"
|
|
|
|
}
|
|
|
|
|
2018-08-11 07:05:49 +00:00
|
|
|
# Test jumping forward til before a character with t
|
|
|
|
send "echo MORE-TEXT-IS-NICE"
|
|
|
|
send "\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.250
|
|
|
|
send "0tTD\r"
|
|
|
|
expect_prompt -re {\r\nMORE\r\n} {
|
|
|
|
puts "vi mode forward-jump-till character, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "vi mode forward-jump-till character, default timeout: long delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test jumping backward til before a character with T
|
|
|
|
send "echo MORE-TEXT-IS-NICE"
|
|
|
|
send "\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.250
|
|
|
|
send "TSD\r"
|
|
|
|
expect_prompt -re {\r\nMORE-TEXT-IS\r\n} {
|
|
|
|
puts "vi mode backward-jump-till character, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "vi mode backward-jump-till character, default timeout: long delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test jumping backward with F and repeating
|
|
|
|
send "echo MORE-TEXT-IS-NICE"
|
|
|
|
send "\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.250
|
|
|
|
send "F-;D\r"
|
|
|
|
expect_prompt -re {\r\nMORE-TEXT\r\n} {
|
|
|
|
puts "vi mode backward-jump-to character and repeat, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "vi mode backward-jump-to character and repeat, default timeout: long delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test jumping backward with F w/reverse jump
|
|
|
|
send "echo MORE-TEXT-IS-NICE"
|
|
|
|
send "\033"
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
sleep 0.250
|
|
|
|
send "F-F-,D\r"
|
|
|
|
expect_prompt -re {\r\nMORE-TEXT-IS\r\n} {
|
|
|
|
puts "vi mode backward-jump-to character, and reverse, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "vi mode backward-jump-to character, and reverse, default timeout: long delay"
|
|
|
|
}
|
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
# Verify that changing the escape timeout has an effect.
|
2016-04-29 04:12:58 +00:00
|
|
|
send "set -g fish_escape_delay_ms 200\r"
|
2016-01-15 05:46:53 +00:00
|
|
|
expect_prompt
|
2016-02-11 02:09:55 +00:00
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
send "echo fail: lengthened escape timeout"
|
2016-01-15 05:46:53 +00:00
|
|
|
send "\033"
|
2018-01-16 17:11:46 +00:00
|
|
|
sleep 0.350
|
2016-01-15 05:46:53 +00:00
|
|
|
send "ddi"
|
2016-02-01 01:37:51 +00:00
|
|
|
send "echo success: lengthened escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: lengthened escape timeout\r\n} {
|
2019-02-07 11:08:24 +00:00
|
|
|
puts "vi replace line, 200ms timeout: long delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
} unmatched {
|
2019-02-07 11:08:24 +00:00
|
|
|
puts stderr "vi replace line, 200ms timeout: long delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that we don't switch to vi normal mode if we don't wait long enough
|
2016-02-01 01:37:51 +00:00
|
|
|
# after sending escape.
|
2016-01-15 05:46:53 +00:00
|
|
|
send "echo fail: no normal mode"
|
|
|
|
send "\033"
|
2018-01-16 17:11:46 +00:00
|
|
|
sleep 0.050
|
2016-01-15 05:46:53 +00:00
|
|
|
send "ddi"
|
|
|
|
send "inserted\r"
|
|
|
|
expect_prompt -re {\r\nfail: no normal modediinserted\r\n} {
|
2019-02-07 11:08:24 +00:00
|
|
|
puts "vi replace line, 200ms timeout: short delay"
|
2015-07-20 07:18:56 +00:00
|
|
|
} unmatched {
|
2019-02-07 11:08:24 +00:00
|
|
|
puts stderr "vi replace line, 200ms timeout: short delay"
|
2015-07-20 07:18:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-03 18:20:08 +00:00
|
|
|
# Test 't' binding that contains non-zero arity function (forward-jump) followed
|
|
|
|
# by another function (and) https://github.com/fish-shell/fish-shell/issues/2357
|
2016-02-03 02:13:08 +00:00
|
|
|
send "\033"
|
2018-01-16 17:11:46 +00:00
|
|
|
sleep 0.300
|
2016-02-03 02:13:08 +00:00
|
|
|
send "ddiecho TEXT\033"
|
2018-01-16 17:11:46 +00:00
|
|
|
sleep 0.300
|
2016-02-03 02:13:08 +00:00
|
|
|
send "hhtTrN\r"
|
2015-09-03 18:20:08 +00:00
|
|
|
expect_prompt -re {\r\nTENT\r\n} {
|
|
|
|
puts "t-binding success"
|
|
|
|
} -nounmatched -re {\r\nfail} {
|
|
|
|
puts stderr "t-binding fail"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'TENT'"
|
|
|
|
}
|
|
|
|
|
2017-03-16 17:35:44 +00:00
|
|
|
# Now test that exactly the expected bind modes are defined
|
|
|
|
send "bind --list-modes\r"
|
2017-04-18 04:23:03 +00:00
|
|
|
expect_prompt -re {\r\ndefault\r\ninsert\r\npaste\r\nreplace_one\r\nvisual\r\n} {
|
2017-03-16 17:35:44 +00:00
|
|
|
puts "vi bind modes"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Unexpected vi bind modes"
|
|
|
|
}
|
|
|
|
|
2015-12-23 23:24:45 +00:00
|
|
|
# Switch back to regular (emacs mode) key bindings.
|
2016-01-15 05:46:53 +00:00
|
|
|
send "set -g fish_key_bindings fish_default_key_bindings\r"
|
2014-09-18 22:45:07 +00:00
|
|
|
expect_prompt
|
2016-01-15 05:46:53 +00:00
|
|
|
|
2016-04-29 04:12:58 +00:00
|
|
|
# Verify the custom escape timeout of 200ms set earlier is still in effect.
|
2016-02-11 02:09:55 +00:00
|
|
|
send "echo fish_escape_delay_ms=\$fish_escape_delay_ms\r"
|
2016-04-29 04:12:58 +00:00
|
|
|
expect_prompt -re {\r\nfish_escape_delay_ms=200\r\n} {
|
2016-02-11 02:09:55 +00:00
|
|
|
puts "default-mode custom timeout set correctly"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "default-mode custom timeout not set correctly"
|
|
|
|
}
|
|
|
|
|
2019-02-07 11:08:24 +00:00
|
|
|
# Set it to 100ms.
|
2016-04-29 04:12:58 +00:00
|
|
|
send "set -g fish_escape_delay_ms 100\r"
|
|
|
|
expect_prompt
|
|
|
|
|
2016-01-15 05:46:53 +00:00
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
|
|
|
send "echo abc def"
|
2016-02-01 01:37:51 +00:00
|
|
|
send "\033"
|
|
|
|
send "t\r"
|
2016-01-15 05:46:53 +00:00
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "emacs transpose words, 100ms timeout: no delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: no delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
}
|
|
|
|
|
2016-01-24 02:24:54 +00:00
|
|
|
|
2016-02-01 01:37:51 +00:00
|
|
|
# Same test as above but with a slight delay less than the escape timeout.
|
2016-01-15 05:46:53 +00:00
|
|
|
send "echo ghi jkl"
|
|
|
|
send "\033"
|
2016-02-01 01:37:51 +00:00
|
|
|
sleep 0.080
|
2016-01-15 05:46:53 +00:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\njkl ghi\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "emacs transpose words, 100ms timeout: short delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: short delay"
|
2016-01-15 05:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
|
|
|
send "echo mno pqr"
|
|
|
|
send "\033"
|
2016-02-11 02:09:55 +00:00
|
|
|
sleep 0.250
|
2016-01-15 05:46:53 +00:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\nmno pqrt\r\n} {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts "emacs transpose words, 100ms timeout: long delay"
|
2014-09-18 22:45:07 +00:00
|
|
|
} unmatched {
|
2016-02-01 01:37:51 +00:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: long delay"
|
2014-09-18 22:45:07 +00:00
|
|
|
}
|
2016-05-25 03:42:50 +00:00
|
|
|
|
|
|
|
# Verify special characters, such as \cV, are not intercepted by the kernel
|
|
|
|
# tty driver. Rather, they can be bound and handled by fish.
|
|
|
|
send "bind \\cV 'echo ctrl-v seen'\r"
|
|
|
|
expect_prompt
|
|
|
|
send "\026\r"
|
|
|
|
expect_prompt -re {ctrl-v seen} {
|
|
|
|
puts "ctrl-v seen"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "ctrl-v not seen"
|
|
|
|
}
|
|
|
|
|
|
|
|
send "bind \\cO 'echo ctrl-o seen'\r"
|
|
|
|
expect_prompt
|
|
|
|
send "\017\r"
|
|
|
|
expect_prompt -re {ctrl-o seen} {
|
|
|
|
puts "ctrl-o seen"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "ctrl-o not seen"
|
|
|
|
}
|
2019-04-26 17:07:33 +00:00
|
|
|
|
|
|
|
# \x17 is ctrl-w.
|
|
|
|
send "echo git@github.com:fish-shell/fish-shell"
|
|
|
|
send "\x17\x17\r"
|
|
|
|
expect_prompt -re {git@github.com:} {
|
|
|
|
puts "ctrl-w stops at :"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "ctrl-w does not stop at :"
|
|
|
|
}
|
|
|
|
|
|
|
|
send "echo git@github.com:fish-shell/fish-shell"
|
|
|
|
send "\x17\x17\x17\r"
|
|
|
|
expect_prompt -re {git@} {
|
|
|
|
puts "ctrl-w stops at @"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "ctrl-w does not stop at @"
|
|
|
|
}
|