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:
parent
a19ed1623f
commit
fee19da230
2 changed files with 15 additions and 1 deletions
|
@ -704,8 +704,8 @@ class Reline::LineEditor
|
||||||
@highest_in_this = height
|
@highest_in_this = height
|
||||||
end
|
end
|
||||||
move_cursor_up(@started_from)
|
move_cursor_up(@started_from)
|
||||||
cursor_up_from_last_line = height - 1 - @started_from
|
|
||||||
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
||||||
|
cursor_up_from_last_line = height - 1 - @started_from
|
||||||
end
|
end
|
||||||
if Reline::Unicode::CSI_REGEXP.match?(prompt + line_to_render)
|
if Reline::Unicode::CSI_REGEXP.match?(prompt + line_to_render)
|
||||||
@output.write "\e[0m" # clear character decorations
|
@output.write "\e[0m" # clear character decorations
|
||||||
|
|
|
@ -678,6 +678,20 @@ begin
|
||||||
EOC
|
EOC
|
||||||
end
|
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)
|
private def write_inputrc(content)
|
||||||
File.open(@inputrc_file, 'w') do |f|
|
File.open(@inputrc_file, 'w') do |f|
|
||||||
f.write content
|
f.write content
|
||||||
|
|
Loading…
Reference in a new issue