ruby-changes:65172
From: aycabta <ko1@a...>
Date: Sun, 7 Feb 2021 05:16:59 +0900 (JST)
Subject: [ruby-changes:65172] fee19da230 (master): [ruby/reline] Autowrap correctly when inserting chars in the middle of a line
https://git.ruby-lang.org/ruby.git/commit/?id=fee19da230 From fee19da2305c2977985206b7db86917d0f7ac8db Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 3 Feb 2021 17:56:49 +0900 Subject: [ruby/reline] Autowrap correctly when inserting chars in the middle of a line https://github.com/ruby/reline/commit/ebaf37255f --- lib/reline/line_editor.rb | 2 +- test/reline/yamatanooroti/test_rendering.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 84cd8a0..31640fd 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -704,8 +704,8 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L704 @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 diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index b583f8d..22c9316 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -678,6 +678,20 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L678 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/