summaryrefslogtreecommitdiff
path: root/lib/reline
diff options
context:
space:
mode:
authortompng <tomoyapenguin@gmail.com>2023-01-09 02:06:52 +0900
committergit <svn-admin@ruby-lang.org>2023-01-18 14:49:29 +0000
commit8e53f09baaec292e399afba5631a83cefbd63fd8 (patch)
tree60ae8c69324c3f8871e6d6fb4e54fe619b31246f /lib/reline
parent976d72a9f51e90e554c0a31aad1768cc2f39f0b4 (diff)
[ruby/reline] Add constant MINIMUM_SCROLLBAR_HEIGHT for scrollbar rendering when dialog content is very long
https://github.com/ruby/reline/commit/d4c95f89ec
Diffstat (limited to 'lib/reline')
-rw-r--r--lib/reline/line_editor.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 9a03903d14..a1402a0f9e 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -52,6 +52,7 @@ class Reline::LineEditor
MenuInfo = Struct.new('MenuInfo', :target, :list)
PROMPT_LIST_CACHE_TIMEOUT = 0.5
+ MINIMUM_SCROLLBAR_HEIGHT = 1
def initialize(config, encoding)
@config = config
@@ -715,7 +716,7 @@ class Reline::LineEditor
moving_distance = (dialog_render_info.contents.size - height) * 2
position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
- bar_height = 1 if bar_height.zero?
+ bar_height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT
dialog.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
else
dialog.scrollbar_pos = nil