Skip to content

Commit d4c95f8

Browse files
committed
Add constant MINIMUM_SCROLLBAR_HEIGHT for scrollbar rendering when dialog content is very long
1 parent 268e02b commit d4c95f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/reline/line_editor.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module CompletionState
5252
MenuInfo = Struct.new('MenuInfo', :target, :list)
5353

5454
PROMPT_LIST_CACHE_TIMEOUT = 0.5
55+
MINIMUM_SCROLLBAR_HEIGHT = 1
5556

5657
def initialize(config, encoding)
5758
@config = config
@@ -713,7 +714,7 @@ def add_dialog_proc(name, p, context = nil)
713714
moving_distance = (dialog_render_info.contents.size - height) * 2
714715
position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
715716
bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
716-
bar_height = 1 if bar_height.zero?
717+
bar_height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT
717718
dialog.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
718719
else
719720
dialog.scrollbar_pos = nil

0 commit comments

Comments
 (0)