[ruby/reline] Clear dialog when just_move_cursor is called with dialog at last line

https://github.com/ruby/reline/commit/05024b968e
This commit is contained in:
aycabta 2022-01-04 14:21:46 +09:00 committed by git
parent 930ebdd7ca
commit 9e79ae539b
2 changed files with 22 additions and 1 deletions

View File

@ -470,8 +470,12 @@ class Reline::LineEditor
@add_newline_to_end_of_buffer = false
else
if @just_cursor_moving and not @rerender_all
@dialogs.each do |dialog|
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
rendered = just_move_cursor
render_dialog((prompt_width + @cursor) % @screen_size.last)
@just_cursor_moving = false
return
elsif @previous_line_index or new_highest_in_this != @highest_in_this

View File

@ -1254,6 +1254,23 @@ begin
EOC
end
def test_clear_dialog_when_just_move_cursor_at_last_line
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
write("class A\n 3\nend\n")
write("\C-p\C-p\C-p\C-e\C-hS")
write("\C-n")
write("1")
close
assert_screen(<<~'EOC')
prompt> 3
prompt> end
=> 3
prompt> class S
prompt> 31
prompt> end
EOC
end
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content