summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroaki Osawa <ikusawasi@gmail.com>2024-06-03 23:05:45 +0900
committergit <svn-admin@ruby-lang.org>2024-06-03 14:05:51 +0000
commit5d33ff36dcc04bd134dc53bedec7c2144658df51 (patch)
tree6aefdaa1042b0839dee23448fce4bec9cb686f2d /test
parent91d4a7ae0c719697db7dd6dd64ca664b60c9de04 (diff)
[ruby/reline] In ed_search_[prev|next]_history, make the cursor come
to the end of the line when there is no search substr (https://github.com/ruby/reline/pull/714) * In ed_search_prev_history, make the cursor come to the end of the line when there is no search substr * In ed_search_next_history, make the cursor come to the end of the line when there is no search substr * Implemented ActionState to search with empty substr if the previous operation was search with empty string. * Use a simple 2-element array to represent action_state https://github.com/ruby/reline/commit/95ee80bd70
Diffstat (limited to 'test')
-rw-r--r--test/reline/test_key_actor_emacs.rb55
1 files changed, 35 insertions, 20 deletions
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index 36fbfd4040..4dddf9c890 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -1242,14 +1242,22 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
'12345' # new
])
# The ed_search_prev_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12aaa')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12356')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12356')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12345', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12356', '')
+ input_key_by_symbol(:ed_search_next_history)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_prev_char)
+ input_key_by_symbol(:ed_next_char)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12aaa', '')
+ 3.times { input_key_by_symbol(:ed_prev_char) }
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12', '356')
end
def test_ed_search_prev_history_without_match
@@ -1291,18 +1299,25 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
'12345' # new
])
# The ed_search_prev_history and ed_search_next_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12aaa')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_line_around_cursor('', '12356')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_line_around_cursor('', '12aaa')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_line_around_cursor('', '12345')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_line_around_cursor('', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12345', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12356', '')
+ input_key_by_symbol(:ed_search_next_history)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_search_next_history)
+ assert_line_around_cursor('12345', '')
+ input_key_by_symbol(:ed_search_prev_history)
+ assert_line_around_cursor('12aaa', '')
+ input_key_by_symbol(:ed_prev_char)
+ input_key_by_symbol(:ed_next_char)
+ input_key_by_symbol(:ed_search_next_history)
+ assert_line_around_cursor('12aaa', '')
+ 3.times { input_key_by_symbol(:ed_prev_char) }
+ input_key_by_symbol(:ed_search_next_history)
+ assert_line_around_cursor('12', '345')
end
def test_incremental_search_history_cancel_by_symbol_key