Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,14 @@ def rerender
end
Reline::IOGate.erase_after_cursor
if with_control
move_cursor_up(height - 1)
# Just after rendring, so the cursor is on the last line.
if finished?
move_cursor_down(@started_from)
Reline::IOGate.move_cursor_column(0)
else
# Moves up from bottom of lines to the cursor position.
move_cursor_up(height - 1 - @started_from)
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
end
move_cursor_down(@started_from)
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
end
height
end
Expand Down
36 changes: 36 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,42 @@ def test_autowrap
EOC
end

def test_finish_autowrapped_line
start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
sleep 0.5
write("[{'user'=>{'email'=>'a@a', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]\n")
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> [{'user'=>{'email'=>'a@a', 'id'=
>'ABC'}, 'version'=>4, 'status'=>'succee
ded'}]
=> [{"user"=>{"email"=>"a@a", "id"=>"ABC
"}, "version"=>4, "status"=>"succeeded"}
]
prompt>
EOC
end

def test_finish_autowrapped_line_in_the_middle_of_lines
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
sleep 0.5
write("[{'user'=>{'email'=>'abcdef@abcdef', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]#{"\C-b"*7}\n")
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> [{'user'=>{'email'=>'a
bcdef@abcdef', 'id'=>'ABC'}, '
version'=>4, 'status'=>'succee
ded'}]
=> [{"user"=>{"email"=>"abcdef
@abcdef", "id"=>"ABC"}, "versi
on"=>4, "status"=>"succeeded"}
]
prompt>
EOC
end

def test_prompt
File.open(@inputrc_file, 'w') do |f|
f.write <<~'LINES'
Expand Down