Fix being able to scroll out of bounds infinitely

This commit is contained in:
lemon-sherbet 2019-12-29 11:37:48 +01:00
parent b798825e7c
commit 194187288f
1 changed files with 5 additions and 0 deletions

View File

@ -300,6 +300,11 @@ end
function DocView:update()
-- clamp to view bounds
local max_scroll = math.max(0, self:get_scrollable_size() - self.size.y)
self.scroll.y = math.min(max_scroll, self.scroll.y)
self.scroll.to.y = math.max(0, math.min(max_scroll, self.scroll.to.y))
-- scroll to make caret visible and reset blink timer if it moved
local line, col = self.doc:get_selection()
if (line ~= self.last_line or col ~= self.last_col) and self.size.x > 0 then