Skip to content

Commit

Permalink
docview: prevent overscroll when DocView size is less than lh * 2 (li…
Browse files Browse the repository at this point in the history
  • Loading branch information
takase1121 authored Dec 2, 2024
1 parent 67752e1 commit 36db156
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/core/docview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ function DocView:scroll_to_make_visible(line, col)
local _, ly = self:get_line_screen_position(line, col)
local lh = self:get_line_height()
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 xoffset = self:get_col_x_offset(line, col)
local xmargin = 3 * self:get_font():get_width(' ')
Expand Down

0 comments on commit 36db156

Please sign in to comment.