Skip to content

Commit

Permalink
Fix the issue where next_chapter moved two chapters if executed inside a
Browse files Browse the repository at this point in the history
chapter (addresses #987)
  • Loading branch information
ahrm committed Feb 27, 2024
1 parent dbe3b39 commit 5b0cd55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pdf_viewer/document_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,10 @@ void DocumentView::goto_chapter(int diff) {
index++;
}

if (index < chapter_pages.size() && chapter_pages[index] > curr_page) {
index--;
}

int new_index = index + diff;
if (new_index < 0) {
goto_page(0);
Expand Down
8 changes: 8 additions & 0 deletions pdf_viewer/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3941,6 +3941,10 @@ class NextChapterCommand : public Command {
widget->main_document_view->goto_chapter(rp);
}

bool pushes_state() {
return true;
}

};

class PrevChapterCommand : public Command {
Expand All @@ -3954,6 +3958,10 @@ class PrevChapterCommand : public Command {
widget->main_document_view->goto_chapter(-rp);
}

bool pushes_state() {
return true;
}

};

class ShowContextMenuCommand : public Command {
Expand Down

0 comments on commit 5b0cd55

Please sign in to comment.