Improve `DocView:get_visible_line_range` precision (#1382)

This commit is contained in:
Guldoman 2023-02-06 19:03:29 +01:00 committed by takase1121
parent 24491bc3fd
commit b0e524dd15
No known key found for this signature in database
GPG Key ID: 60EEFFC68EB3031B
1 changed files with 2 additions and 2 deletions

View File

@ -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