From e2fbade2195a94e350610e254a2ca4d051cc35e0 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sun, 11 Sep 2022 18:56:43 -0700 Subject: [PATCH] fix scrollbar display when all text is visible also align behavior with documentation when 'left' or 'right' is explicitly specified (i.e. always show the scrollbar) --- library/lua/gui/widgets.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 76683b45a..e85ac2d3c 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -599,8 +599,8 @@ local function get_scrollbar_pos_and_height(label) local scrollbar_body_height = label.frame_body.height - 2 local displayed_lines = last_visible_line - first_visible_line - local height = math.min(scrollbar_body_height - 1, - math.ceil((displayed_lines-1) * scrollbar_body_height / text_height)) + local height = math.floor(((displayed_lines-1) * scrollbar_body_height) / + text_height) local max_pos = scrollbar_body_height - height local pos = math.ceil(((first_visible_line-1) * max_pos) / @@ -683,7 +683,6 @@ end function Label:onRenderFrame(dc, rect) if self._show_scrollbar - and self:getTextHeight() > self.frame_body.height then local x = self._show_scrollbar == 'left' and self.frame_body.x1-dc.x1-1