1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Autowrap correctly when inserting chars in the middle of a line

https://github.com/ruby/reline/commit/ebaf37255f
This commit is contained in:
aycabta 2021-02-03 17:56:49 +09:00
parent a19ed1623f
commit fee19da230
2 changed files with 15 additions and 1 deletions

View file

@ -704,8 +704,8 @@ class Reline::LineEditor
@highest_in_this = height
end
move_cursor_up(@started_from)
cursor_up_from_last_line = height - 1 - @started_from
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
cursor_up_from_last_line = height - 1 - @started_from
end
if Reline::Unicode::CSI_REGEXP.match?(prompt + line_to_render)
@output.write "\e[0m" # clear character decorations

View file

@ -678,6 +678,20 @@ begin
EOC
end
def test_autowrap_in_the_middle_of_a_line
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
write("def abcdefg; end\C-b\C-b\C-b\C-b\C-b")
%w{h i}.each do |c|
write(c)
end
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> def abcdefgh
i; end
EOC
end
private def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content