mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 23:11:14 -03:00
change default escape timeout
This changes the default escape timeout for the default keybindings (emacs mode) to 300ms and the default for vi keybindings to 10ms. I couldn't resist fixing a few nits in the fish_vi_key_bindings.fish file since I was touching it to set the escape timeout.
This commit is contained in:
committed by
ridiculousfish
parent
e88bfbc440
commit
2646d51a0b
@@ -2,96 +2,8 @@
|
||||
spawn $fish
|
||||
expect_prompt
|
||||
|
||||
# Test switching key bindings to vi mode. This should leave the mode in the
|
||||
# appropriate state (i.e., insert mode). These initial tests assume the
|
||||
# default escape timeout of 500ms is in effect.
|
||||
|
||||
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
||||
expect_prompt
|
||||
|
||||
# This test is only present to make the Travis-CI framework succeed
|
||||
# consistently. It's not clear why the following tests succeed without this
|
||||
# test when executed on a local machine but not in the Travis-CI framework.
|
||||
send "echo success: default escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
||||
puts "prime vi mode: default escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "prime vi mode fail: default escape timeout"
|
||||
}
|
||||
|
||||
send "echo fail: default escape timeout"
|
||||
send "\033"
|
||||
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||
sleep 0.550
|
||||
send "ddi"
|
||||
send "echo success: default escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
||||
puts "vi replace line: default escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "vi replace line fail: default escape timeout"
|
||||
}
|
||||
|
||||
# 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"
|
||||
send "\033"
|
||||
# Fish should still be in vi insert mode after this delay to simulate a slow
|
||||
# typist.
|
||||
sleep 0.400
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\ndef abc\r\n} {
|
||||
puts "vi transpose words: default escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "vi transpose words fail: default escape timeout"
|
||||
}
|
||||
|
||||
# Test replacing a single character.
|
||||
send "echo TEXT"
|
||||
send "\033"
|
||||
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||
sleep 0.550
|
||||
send "hhrAi\r"
|
||||
expect_prompt -re {\r\nTAXT\r\n} {
|
||||
puts "vi mode replace: default escape timeout"
|
||||
} -nounmatched -re {\r\nfail} {
|
||||
puts stderr "vi mode replace fail: default escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "couldn't find expected output 'TAXT': default escape timeout"
|
||||
}
|
||||
|
||||
# Verify that changing the escape timeout has an effect. The vi key bindings
|
||||
# should still be in effect.
|
||||
send "set -g fish_escape_delay_ms 100\r"
|
||||
expect_prompt
|
||||
send "echo fail: shortened escape timeout"
|
||||
send "\033"
|
||||
sleep 0.150
|
||||
send "ddi"
|
||||
send "echo success: shortened escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: shortened escape timeout\r\n} {
|
||||
puts "vi replace line: shortened escape timeout"
|
||||
} -nounmatched -re {\r\nfail} {
|
||||
puts stderr "vi replace line fail: shortened escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "couldn't find expected output: replace_line, shortened escape timeout"
|
||||
}
|
||||
|
||||
# Verify that we don't switch to vi normal mode if we don't wait long enough
|
||||
# after sending escape. The vi key bindings should still be in effect.
|
||||
send "echo fail: no normal mode"
|
||||
send "\033"
|
||||
sleep 0.050
|
||||
send "ddi"
|
||||
send "inserted\r"
|
||||
expect_prompt -re {\r\nfail: no normal modediinserted\r\n} {
|
||||
puts "vi normal mode: shortened escape timeout"
|
||||
} unmatched {
|
||||
puts stderr "couldn't find expected output: no normal mode"
|
||||
}
|
||||
|
||||
# Switch back to regular (emacs mode) key bindings.
|
||||
send "set -g fish_key_bindings fish_default_key_bindings\r"
|
||||
expect_prompt
|
||||
# Fish should start in default-mode (i.e., emacs) bindings. The default escape
|
||||
# timeout is 300ms.
|
||||
|
||||
# Verify the emacs transpose word (\et) behavior using various delays,
|
||||
# including none, after the escape character.
|
||||
@@ -100,34 +12,154 @@ expect_prompt
|
||||
send "echo abc def"
|
||||
send "\033t\r"
|
||||
expect_prompt -re {\r\ndef abc\r\n} {
|
||||
puts "emacs transpose words: no escape delay"
|
||||
puts "emacs transpose words, default timeout: no delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail: no escape delay"
|
||||
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 "set -g fish_escape_delay_ms 100\r"
|
||||
expect_prompt
|
||||
|
||||
send "echo ghi jkl"
|
||||
send "\033"
|
||||
sleep 0.050
|
||||
sleep 0.200
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\njkl ghi\r\n} {
|
||||
puts "emacs transpose words: short escape delay"
|
||||
puts "emacs transpose words, default timeout: short delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail: short escape delay"
|
||||
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"
|
||||
sleep 0.150
|
||||
sleep 0.400
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\nmno pqrt\r\n} {
|
||||
puts "emacs transpose words: long escape delay"
|
||||
puts "emacs transpose words, default timeout: long delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail: long escape delay"
|
||||
puts stderr "emacs transpose words fail, default timeout: long delay"
|
||||
}
|
||||
|
||||
# Test vi key bindings.
|
||||
# This should leave vi mode in the insert state.
|
||||
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
||||
expect_prompt
|
||||
|
||||
# These vi tests assume the fish_vi_key_bindings default escape timeout of
|
||||
# 10ms is in effect; not the 300ms timeout for the default-mode.
|
||||
#
|
||||
# This test is only present to make the Travis-CI framework succeed
|
||||
# consistently. It's not clear why the subsequent tests succeed without this
|
||||
# test when executed on a local machine but not in the Travis-CI framework.
|
||||
send "echo success: default escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
||||
puts "prime vi mode, default timeout"
|
||||
} unmatched {
|
||||
puts stderr "prime vi mode, default timeout"
|
||||
}
|
||||
|
||||
send "echo fail: default escape timeout"
|
||||
send "\033"
|
||||
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||
sleep 0.020
|
||||
send "ddi"
|
||||
send "echo success: default escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
||||
puts "vi replace line, default timeout: long delay"
|
||||
} unmatched {
|
||||
puts stderr "vi replace line, default timeout: long delay"
|
||||
}
|
||||
|
||||
# Verify that a human can transpose words using \et (which is an emacs default
|
||||
# binding but should be valid while in vi insert or normal mode).
|
||||
send "echo abc def"
|
||||
send "\033"
|
||||
sleep 0.005
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\ndef abc\r\n} {
|
||||
puts "vi transpose words, default timeout: short delay"
|
||||
} unmatched {
|
||||
puts stderr "vi transpose words, default timeout: short delay"
|
||||
}
|
||||
|
||||
# Test replacing a single character.
|
||||
send "echo TEXT"
|
||||
send "\033"
|
||||
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||
sleep 0.020
|
||||
send "hhrAi\r"
|
||||
expect_prompt -re {\r\nTAXT\r\n} {
|
||||
puts "vi mode replace char, default timeout: long delay"
|
||||
} unmatched {
|
||||
puts stderr "vi mode replace char, default timeout: long delay"
|
||||
}
|
||||
|
||||
# Verify that changing the escape timeout has an effect.
|
||||
send "set -g fish_escape_delay_ms 100\r"
|
||||
expect_prompt
|
||||
send "echo fail: lengthened escape timeout"
|
||||
send "\033"
|
||||
sleep 0.150
|
||||
send "ddi"
|
||||
send "echo success: lengthened escape timeout\r"
|
||||
expect_prompt -re {\r\nsuccess: lengthened escape timeout\r\n} {
|
||||
puts "vi replace line, 100ms timeout: long delay"
|
||||
} unmatched {
|
||||
puts stderr "vi replace line, 100ms timeout: long delay"
|
||||
}
|
||||
|
||||
# Verify that we don't switch to vi normal mode if we don't wait long enough
|
||||
# after sending escape.
|
||||
send "echo fail: no normal mode"
|
||||
send "\033"
|
||||
sleep 0.050
|
||||
send "ddi"
|
||||
send "inserted\r"
|
||||
expect_prompt -re {\r\nfail: no normal modediinserted\r\n} {
|
||||
puts "vi replace line, 100ms timeout: short delay"
|
||||
} unmatched {
|
||||
puts stderr "vi replace line, 100ms timeout: short delay"
|
||||
}
|
||||
|
||||
# Switch back to regular (emacs mode) key bindings.
|
||||
# The custom escape timeout of 100ms set earlier should still be in effect.
|
||||
send "set -g fish_key_bindings fish_default_key_bindings\r"
|
||||
expect_prompt
|
||||
|
||||
# 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 "\033"
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\ndef abc\r\n} {
|
||||
puts "emacs transpose words, 100ms timeout: no delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail, 100ms timeout: no delay"
|
||||
}
|
||||
|
||||
|
||||
# Same test as above but with a slight delay less than the escape timeout.
|
||||
send "echo ghi jkl"
|
||||
send "\033"
|
||||
sleep 0.080
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\njkl ghi\r\n} {
|
||||
puts "emacs transpose words, 100ms timeout: short delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail, 100ms 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"
|
||||
sleep 0.120
|
||||
send "t\r"
|
||||
expect_prompt -re {\r\nmno pqrt\r\n} {
|
||||
puts "emacs transpose words, 100ms timeout: long delay"
|
||||
} unmatched {
|
||||
puts stderr "emacs transpose words fail, 100ms timeout: long delay"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
prime vi mode: default escape timeout
|
||||
vi replace line: default escape timeout
|
||||
vi transpose words: default escape timeout
|
||||
vi mode replace: default escape timeout
|
||||
vi replace line: shortened escape timeout
|
||||
vi normal mode: shortened escape timeout
|
||||
emacs transpose words: no escape delay
|
||||
emacs transpose words: short escape delay
|
||||
emacs transpose words: long escape delay
|
||||
emacs transpose words, default timeout: no delay
|
||||
emacs transpose words, default timeout: short delay
|
||||
emacs transpose words, default timeout: long delay
|
||||
prime vi mode, default timeout
|
||||
vi replace line, default timeout: long delay
|
||||
vi transpose words, default timeout: short delay
|
||||
vi mode replace char, default timeout: long delay
|
||||
vi replace line, 100ms timeout: long delay
|
||||
vi replace line, 100ms timeout: short delay
|
||||
emacs transpose words, 100ms timeout: no delay
|
||||
emacs transpose words, 100ms timeout: short delay
|
||||
emacs transpose words, 100ms timeout: long delay
|
||||
|
||||
Reference in New Issue
Block a user