ruby-changes:70186
From: aycabta <ko1@a...>
Date: Mon, 13 Dec 2021 20:44:38 +0900 (JST)
Subject: [ruby-changes:70186] 8411e8449b (master): [ruby/reline] Remove unnecessary variables, lower_space
https://git.ruby-lang.org/ruby.git/commit/?id=8411e8449b From 8411e8449b17357221b69617214674fb101c766d Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 8 Dec 2021 01:44:18 +0900 Subject: [ruby/reline] Remove unnecessary variables, lower_space The number of lines below the cursor position was known by "@rest_height" alone, but the problem was caused by adding "lower_space". Remove "lower_space" as it is unnecessary. https://github.com/ruby/reline/commit/a575cef6a3 --- lib/reline/line_editor.rb | 5 ++--- test/reline/yamatanooroti/test_rendering.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 50bd22b424a..39e2b427bcb 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -706,19 +706,18 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L706 dialog.scrollbar_pos = nil end upper_space = @first_line_started_from - @started_from - lower_space = @highest_in_all - @first_line_started_from - @started_from - 1 dialog.column = dialog_render_info.pos.x dialog.width += @block_elem_width if dialog.scrollbar_pos diff = (dialog.column + dialog.width) - (@screen_size.last) if diff > 0 dialog.column -= diff end - if (lower_space + @rest_height - dialog_render_info.pos.y) >= height + if (@rest_height - dialog_render_info.pos.y) >= height dialog.vertical_offset = dialog_render_info.pos.y + 1 elsif upper_space >= height dialog.vertical_offset = dialog_render_info.pos.y - height else - if (lower_space + @rest_height - dialog_render_info.pos.y) < height + if (@rest_height - dialog_render_info.pos.y) < height scroll_down(height + dialog_render_info.pos.y) move_cursor_up(height + dialog_render_info.pos.y) end diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 7ac426cfb41..3410af762fa 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1197,6 +1197,26 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L1197 EOC end + def test_bottom + start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.') + write("\n\n\n\n\n\n") + write("def hoge\n\n\n\n\n\n\nend\C-p\C-p\C-p\C-e") + write(" S") + close + assert_screen(<<~'EOC') + prompt> def hoge + prompt> + prompt> + prompt> + prompt> S + prompt> String + prompt> Struct + prompt> enSymbol + ScriptError + Signal + EOC + end + def write_inputrc(content) File.open(@inputrc_file, 'w') do |f| f.write content -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/