amend #2914 so lists don't jump around on resize

develop
Myk Taylor 2023-05-20 04:38:03 -07:00
parent 51fa088605
commit 9dffba6843
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 3 additions and 11 deletions

@ -1664,9 +1664,7 @@ function List:setChoices(choices, selected)
-- Check if page_top needs to be adjusted -- Check if page_top needs to be adjusted
if #self.choices - self.page_size < 0 then if #self.choices - self.page_size < 0 then
self.page_top = 1 self.page_top = 1
elseif self.selected <= (self.page_size // 2) then elseif self.page_top > #self.choices - self.page_size + 1 then
self.page_top = 1
elseif self.selected >= #self.choices - (self.page_size // 2) then
self.page_top = #self.choices - self.page_size + 1 self.page_top = #self.choices - self.page_size + 1
end end
end end
@ -1719,14 +1717,8 @@ function List:postComputeFrame(body)
return return
end end
local max_page_top = math.max(1, num_choices - row_count + 1) if self.page_top > num_choices - self.page_size + 1 then
self.page_top = math.max(1, num_choices - self.page_size + 1)
if self.selected > num_choices - row_count then
self.page_top = max_page_top
elseif self.selected < self.page_top then
self.page_top = self.selected
else
self.page_top = math.max(1, self.selected - row_count + 1)
end end
update_list_scrollbar(self) update_list_scrollbar(self)