[ruby/reline] Fix: line longer than terminal width breaks rendering

(https://github.com/ruby/reline/pull/516)

https://github.com/ruby/reline/commit/ae5f9b87ab
This commit is contained in:
tomoya ishida 2023-03-18 23:37:05 +09:00 committed by git
parent cb22d78354
commit e8e7ff1333
2 changed files with 18 additions and 0 deletions

View File

@ -972,6 +972,7 @@ class Reline::LineEditor
prev_line_prompt = @prompt_proc ? prompt_list[@line_index - 1] : prompt
prev_line_prompt_width = @prompt_proc ? calculate_width(prev_line_prompt, true) : prompt_width
prev_line = modify_lines(lines)[@line_index - 1]
move_cursor_up(@started_from)
render_partial(prev_line_prompt, prev_line_prompt_width, prev_line, @first_line_started_from + @started_from, with_control: false)
scroll_down(1)
render_partial(prompt, prompt_width, @line, @first_line_started_from + @started_from + 1, with_control: false)

View File

@ -281,6 +281,23 @@ begin
EOC
end
def test_multiline_add_new_line_and_autowrap
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("def aaaaaaaaaa")
write("\n")
write(" bbbbbbbbbbbb")
write("\n")
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> def aaaaaaaa
aa
prompt> bbbbbbbbbb
bb
prompt>
EOC
end
def test_clear
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("3\C-l")