Skip to content

Commit

Permalink
[ruby/reline] Autowrap correctly when inserting chars in the middle o…
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Feb 6, 2021
1 parent a19ed16 commit fee19da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Expand Up @@ -704,8 +704,8 @@ def just_move_cursor
@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
Expand Down
14 changes: 14 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Expand Up @@ -678,6 +678,20 @@ def test_suppress_auto_indent_for_adding_newlines_in_pasting
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
Expand Down

0 comments on commit fee19da

Please sign in to comment.