mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Search history to back in the middle of histories
This commit is contained in:
parent
4d7a6d04b2
commit
e15b0313a7
2 changed files with 29 additions and 5 deletions
|
@ -1145,10 +1145,12 @@ class Reline::LineEditor
|
||||||
alias_method :end_of_line, :ed_move_to_end
|
alias_method :end_of_line, :ed_move_to_end
|
||||||
|
|
||||||
private def ed_search_prev_history(key)
|
private def ed_search_prev_history(key)
|
||||||
if @is_multiline
|
unless @history_pointer
|
||||||
@line_backup_in_history = whole_buffer
|
if @is_multiline
|
||||||
else
|
@line_backup_in_history = whole_buffer
|
||||||
@line_backup_in_history = @line
|
else
|
||||||
|
@line_backup_in_history = @line
|
||||||
|
end
|
||||||
end
|
end
|
||||||
searcher = Fiber.new do
|
searcher = Fiber.new do
|
||||||
search_word = String.new(encoding: @encoding)
|
search_word = String.new(encoding: @encoding)
|
||||||
|
@ -1171,7 +1173,7 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
hit = nil
|
hit = nil
|
||||||
if @line_backup_in_history.include?(search_word)
|
if @line_backup_in_history&.include?(search_word)
|
||||||
@history_pointer = nil
|
@history_pointer = nil
|
||||||
hit = @line_backup_in_history
|
hit = @line_backup_in_history
|
||||||
else
|
else
|
||||||
|
|
|
@ -1430,6 +1430,28 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
||||||
assert_cursor_max(0)
|
assert_cursor_max(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_search_history_to_back_in_the_middle_of_histories
|
||||||
|
Reline::HISTORY.concat([
|
||||||
|
'1235', # old
|
||||||
|
'12aa',
|
||||||
|
'1234' # new
|
||||||
|
])
|
||||||
|
assert_line('')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(0)
|
||||||
|
input_keys("\C-p\C-p")
|
||||||
|
assert_line('12aa')
|
||||||
|
assert_byte_pointer_size('12aa')
|
||||||
|
assert_cursor(4)
|
||||||
|
assert_cursor_max(4)
|
||||||
|
input_keys("\C-r123")
|
||||||
|
assert_line('1235')
|
||||||
|
assert_byte_pointer_size('1235')
|
||||||
|
assert_cursor(4)
|
||||||
|
assert_cursor_max(4)
|
||||||
|
end
|
||||||
|
|
||||||
def test_em_set_mark_and_em_exchange_mark
|
def test_em_set_mark_and_em_exchange_mark
|
||||||
input_keys('aaa bbb ccc ddd')
|
input_keys('aaa bbb ccc ddd')
|
||||||
assert_byte_pointer_size('aaa bbb ccc ddd')
|
assert_byte_pointer_size('aaa bbb ccc ddd')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue