mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Move cursor to currect vertical pos after rendering a logical line
9b932df544
This commit is contained in:
parent
9baf1bd0a4
commit
ce389ade45
2 changed files with 42 additions and 4 deletions
|
@ -524,13 +524,15 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
Reline::IOGate.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
if with_control
|
if with_control
|
||||||
move_cursor_up(height - 1)
|
# Just after rendring, so the cursor is on the last line.
|
||||||
if finished?
|
if finished?
|
||||||
move_cursor_down(@started_from)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
end
|
else
|
||||||
move_cursor_down(@started_from)
|
# 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)
|
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
height
|
height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,42 @@ begin
|
||||||
EOC
|
EOC
|
||||||
end
|
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
|
def test_prompt
|
||||||
File.open(@inputrc_file, 'w') do |f|
|
File.open(@inputrc_file, 'w') do |f|
|
||||||
f.write <<~'LINES'
|
f.write <<~'LINES'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue