Viewer: Fix remembered position sometimes off by one page in paged mode. Fixes #1847322 [Viewer opens to wrong page](https://bugs.launchpad.net/calibre/+bug/1847322)

This commit is contained in:
Kovid Goyal 2019-10-09 09:13:09 +05:30
parent 5d272e86e8
commit 1cdface5ad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -6,7 +6,7 @@ import traceback
from gettext import gettext as _ from gettext import gettext as _
from iframe_comm import IframeClient from iframe_comm import IframeClient
from read_book.cfi import at_current, scroll_to as scroll_to_cfi from read_book.cfi import scroll_to as scroll_to_cfi
from read_book.extract import get_elements from read_book.extract import get_elements
from read_book.flow_mode import ( from read_book.flow_mode import (
anchor_funcs as flow_anchor_funcs, flow_onwheel, flow_to_scroll_fraction, anchor_funcs as flow_anchor_funcs, flow_onwheel, flow_to_scroll_fraction,
@ -20,7 +20,7 @@ from read_book.globals import (
) )
from read_book.mathjax import apply_mathjax from read_book.mathjax import apply_mathjax
from read_book.paged_mode import ( from read_book.paged_mode import (
anchor_funcs as paged_anchor_funcs, calc_columns_per_screen, anchor_funcs as paged_anchor_funcs, calc_columns_per_screen, current_cfi,
handle_gesture as paged_handle_gesture, handle_shortcut as paged_handle_shortcut, handle_gesture as paged_handle_gesture, handle_shortcut as paged_handle_shortcut,
jump_to_cfi as paged_jump_to_cfi, layout as paged_layout, jump_to_cfi as paged_jump_to_cfi, layout as paged_layout,
onwheel as paged_onwheel, progress_frac, reset_paged_mode_globals, onwheel as paged_onwheel, progress_frac, reset_paged_mode_globals,
@ -305,7 +305,7 @@ class IframeBoss:
return ans return ans
def get_current_cfi(self, data): def get_current_cfi(self, data):
cfi = at_current() cfi = current_cfi()
selected_text = window.getSelection().toString() selected_text = window.getSelection().toString()
if cfi: if cfi:
spine = self.book.manifest.spine spine = self.book.manifest.spine
@ -321,7 +321,7 @@ class IframeBoss:
'report_cfi', cfi=None, progress_frac=0, file_progress_frac=0, selected_text=selected_text, request_id=data.request_id) 'report_cfi', cfi=None, progress_frac=0, file_progress_frac=0, selected_text=selected_text, request_id=data.request_id)
def update_cfi(self): def update_cfi(self):
cfi = at_current() cfi = current_cfi()
if cfi: if cfi:
spine = self.book.manifest.spine spine = self.book.manifest.spine
current_name = current_spine_item().name current_name = current_spine_item().name