docview: prevent overscroll when DocView size is less than lh * 2 (#1971)

This commit is contained in:
Takase
2024-12-04 13:02:06 +08:00
committed by takase1121
parent d436dfe9bf
commit 451bfacaf5
+2 -1
View File
@@ -259,7 +259,8 @@ function DocView:scroll_to_make_visible(line, col)
local _, ly = self:get_line_screen_position(line, col) local _, ly = self:get_line_screen_position(line, col)
local lh = self:get_line_height() local lh = self:get_line_height()
local _, _, _, scroll_h = self.h_scrollbar:get_track_rect() local _, _, _, scroll_h = self.h_scrollbar:get_track_rect()
self.scroll.to.y = common.clamp(self.scroll.to.y, ly - oy - self.size.y + scroll_h + lh * 2, ly - oy - lh) local overscroll = math.min(lh * 2, self.size.y) -- always show the previous / next line when possible
self.scroll.to.y = common.clamp(self.scroll.to.y, ly - oy - self.size.y + scroll_h + overscroll, ly - oy - lh)
local gw = self:get_gutter_width() local gw = self:get_gutter_width()
local xoffset = self:get_col_x_offset(line, col) local xoffset = self:get_col_x_offset(line, col)
local xmargin = 3 * self:get_font():get_width(' ') local xmargin = 3 * self:get_font():get_width(' ')