Skip to content

Commit

Permalink
Fix: line longer than terminal width breaks rendering (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Mar 18, 2023
1 parent 20dfab3 commit ae5f9b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ def add_dialog_proc(name, p, context = nil)
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)
Expand Down
17 changes: 17 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,23 @@ def test_multiline_and_autowrap
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")
Expand Down

0 comments on commit ae5f9b8

Please sign in to comment.