ruby-changes:68227
From: aycabta <ko1@a...>
Date: Sun, 3 Oct 2021 21:51:11 +0900 (JST)
Subject: [ruby-changes:68227] 64e96d6b41 (master): [ruby/reline] Re-calc the scroll pos when the content in dialog is shortened
https://git.ruby-lang.org/ruby.git/commit/?id=64e96d6b41 From 64e96d6b4100cd7ef53ed1a7d14c1298ccb0eb23 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Sun, 3 Oct 2021 18:25:26 +0900 Subject: [ruby/reline] Re-calc the scroll pos when the content in dialog is shortened https://github.com/ruby/reline/commit/12ea63e6e0 --- lib/reline/line_editor.rb | 3 +++ test/reline/yamatanooroti/multiline_repl | 7 +++++++ test/reline/yamatanooroti/test_rendering.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 1722abc939..d4a3e06a3d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -673,6 +673,9 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L673 end dialog.contents = dialog.contents[dialog.scroll_top, height] end + if dialog.contents and dialog.scroll_top >= dialog.contents.size + dialog.scroll_top = dialog.contents.size - height + end if dialog_render_info.scrollbar and dialog_render_info.contents.size > height bar_max_height = height * 2 moving_distance = (dialog_render_info.contents.size - height) * 2 diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl index c9036f71b4..b80d1b3ab2 100755 --- a/test/reline/yamatanooroti/multiline_repl +++ b/test/reline/yamatanooroti/multiline_repl @@ -115,6 +115,13 @@ opt.on('--autocomplete-long') { https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/multiline_repl#L115 }.select{ |c| c.start_with?(target) } } } +opt.on('--autocomplete-super-long') { + Reline.autocompletion = true + Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil| + c = 'A' + 2000.times.map{ s = "Str_#{c}"; c.succ!; s }.select{ |c| c.start_with?(target) } + } +} opt.parse!(ARGV) begin diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index f5274cc787..c26e998a11 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1057,6 +1057,33 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L1057 EOC end + def test_autocomplete_super_long_and_backspace + start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-super-long}, startup_message: 'Multiline REPL.') + shift_tab = [27, 91, 90] + write('S' + shift_tab.map(&:chr).join) + write("\C-h") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> Str_BX + Str_BX + Str_BXA + Str_BXB + Str_BXC + Str_BXD + Str_BXE + Str_BXF + Str_BXG + Str_BXH + Str_BXI + Str_BXJ + Str_BXK + Str_BXL + Str_BXM + Str_BXN + EOC + end + def test_dialog_callback_returns_nil start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog nil}, startup_message: 'Multiline REPL.') write('a') -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/