From c6d269d35e6af16753219eb67105641bc446a025 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 6 Feb 2023 19:03:29 +0100 Subject: [PATCH] Improve `DocView:get_visible_line_range` precision (#1382) --- data/core/docview.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/core/docview.lua b/data/core/docview.lua index bf222738..1c3ff6de 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -160,8 +160,8 @@ end function DocView:get_visible_line_range() local x, y, x2, y2 = self:get_content_bounds() local lh = self:get_line_height() - local minline = math.max(1, math.floor(y / lh)) - local maxline = math.min(#self.doc.lines, math.floor(y2 / lh) + 1) + local minline = math.max(1, math.floor((y - style.padding.y) / lh) + 1) + local maxline = math.min(#self.doc.lines, math.floor((y2 - style.padding.y) / lh) + 1) return minline, maxline end