summaryrefslogtreecommitdiff
path: root/test/reline
diff options
context:
space:
mode:
authortomoya ishida <[email protected]>2024-10-03 02:46:59 +0900
committergit <[email protected]>2024-10-02 17:47:02 +0000
commit09761e4789d04eff1f407dcb9afcc2f5f93b541f (patch)
treeaf1c645713399e3030c03cfd8844974b876fe4ce /test/reline
parent8f4277f40594333a7dcad21fe0ef9138a909e777 (diff)
[ruby/reline] Fix incremental search cancel bug
(https://github.com/ruby/reline/pull/748) https://github.com/ruby/reline/commit/bf0f8fa333
Diffstat (limited to 'test/reline')
-rw-r--r--test/reline/test_key_actor_emacs.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index 4dddf9c890..dc12c803f5 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -1328,6 +1328,29 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
assert_line_around_cursor('abd', 'c')
end
+ def test_incremental_search_history_saves_and_restores_last_input
+ Reline::HISTORY.concat(['abc', '123'])
+ input_keys("abcd")
+ # \C-j: terminate incremental search
+ input_keys("\C-r12\C-j")
+ assert_line_around_cursor('', '123')
+ input_key_by_symbol(:ed_next_history)
+ assert_line_around_cursor('abcd', '')
+ # Most non-printable keys also terminates incremental search
+ input_keys("\C-r12\C-i")
+ assert_line_around_cursor('', '123')
+ input_key_by_symbol(:ed_next_history)
+ assert_line_around_cursor('abcd', '')
+ # \C-g: cancel incremental search and restore input, cursor position and history index
+ input_key_by_symbol(:ed_prev_history)
+ input_keys("\C-b\C-b")
+ assert_line_around_cursor('1', '23')
+ input_keys("\C-rab\C-g")
+ assert_line_around_cursor('1', '23')
+ input_key_by_symbol(:ed_next_history)
+ assert_line_around_cursor('abcd', '')
+ end
+
# Unicode emoji test
def test_ed_insert_for_include_zwj_emoji
omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8