mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix a regression that caused syncing of the preview panel to the editor cursor position to not work when the cursor is positioned on a blank line in between two tag definitions
This commit is contained in:
parent
725e1b9a88
commit
b4b4a6f179
@ -353,16 +353,23 @@ class HTMLSmarts(NullSmarts):
|
||||
block = cursor.block()
|
||||
offset = cursor.position() - block.position()
|
||||
nblock, boundary = next_tag_boundary(block, offset, forward=False)
|
||||
if nblock is None:
|
||||
if boundary is None:
|
||||
return None, None
|
||||
if boundary.is_start:
|
||||
# We are inside a tag, use this tag
|
||||
start_block, start_offset = nblock, boundary.offset
|
||||
else:
|
||||
tag = find_closest_containing_tag(block, offset)
|
||||
if tag is None:
|
||||
start_block = None
|
||||
while start_block is None and block.isValid():
|
||||
ud = block.userData()
|
||||
if ud is not None:
|
||||
for boundary in reversed(ud.tags):
|
||||
if boundary.is_start and not boundary.closing and boundary.offset <= offset:
|
||||
start_block, start_offset = block, boundary.offset
|
||||
break
|
||||
block, offset = block.previous(), sys.maxint
|
||||
if start_block is None:
|
||||
return None, None
|
||||
start_block, start_offset = tag.start_block, tag.start_offset
|
||||
sourceline = start_block.blockNumber() + 1 # blockNumber() is zero based
|
||||
ud = start_block.userData()
|
||||
if ud is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user