mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Fix incremental search to work correctly even if not last line
https://github.com/ruby/reline/commit/21d75f6d4c
This commit is contained in:
parent
921ff739df
commit
f5e3913737
2 changed files with 25 additions and 0 deletions
|
@ -2233,6 +2233,8 @@ class Reline::LineEditor
|
|||
@buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
|
||||
@line_index = @buffer_of_lines.size - 1
|
||||
@line = @buffer_of_lines.last
|
||||
@byte_pointer = @line.bytesize
|
||||
@cursor = @cursor_max = calculate_width(@line)
|
||||
@rerender_all = true
|
||||
@searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
|
||||
else
|
||||
|
|
|
@ -1310,6 +1310,29 @@ begin
|
|||
EOC
|
||||
end
|
||||
|
||||
def test_incremental_search_on_not_last_line
|
||||
start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
||||
write("def abc\nend\n")
|
||||
write("def def\nend\n")
|
||||
write("\C-p\C-p\C-e")
|
||||
write("\C-r")
|
||||
write("a")
|
||||
write("\n\n")
|
||||
close
|
||||
assert_screen(<<~'EOC')
|
||||
prompt> def abc
|
||||
prompt> end
|
||||
=> :abc
|
||||
prompt> def def
|
||||
prompt> end
|
||||
=> :def
|
||||
prompt> def abc
|
||||
prompt> end
|
||||
=> :abc
|
||||
prompt>
|
||||
EOC
|
||||
end
|
||||
|
||||
def write_inputrc(content)
|
||||
File.open(@inputrc_file, 'w') do |f|
|
||||
f.write content
|
||||
|
|
Loading…
Reference in a new issue