From bc5881668e44a64f15a9d97d5f6498ec6157d4ea Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 2 Apr 2021 18:12:10 +0200 Subject: [PATCH] TOC: highlight first chapter on page instead of last So its in sync with the chapter shown in the footer, which was previously fixed with a482baac. --- frontend/apps/reader/modules/readertoc.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index 0f7e78cc2..4b4176688 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -564,8 +564,14 @@ end function ReaderToc:updateCurrentNode() if #self.collapsed_toc > 0 and self.pageno then for i, v in ipairs(self.collapsed_toc) do - if v.page > self.pageno then - self.collapsed_toc.current = i > 1 and i - 1 or 1 + if v.page >= self.pageno then + if v.page == self.pageno then + -- Use first TOC item on current page (which may have others) + self.collapsed_toc.current = i + else + -- Use previous TOC item (if any), which is on a previous page + self.collapsed_toc.current = i > 1 and i - 1 or 1 + end return end end