mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix detection of selected highlights when all text is selected. See #2003908 (Clear selection when several selections are selected only deletes one)
This commit is contained in:
parent
be4e875706
commit
40ca12ff39
@ -31,8 +31,9 @@ def text_nodes_in_range(r):
|
|||||||
def first_annot_in_range(r, annot_id_uuid_map):
|
def first_annot_in_range(r, annot_id_uuid_map):
|
||||||
parent = r.commonAncestorContainer
|
parent = r.commonAncestorContainer
|
||||||
doc = parent.ownerDocument or document
|
doc = parent.ownerDocument or document
|
||||||
|
is_full_tree = parent is doc.documentElement
|
||||||
|
in_range = not is_full_tree
|
||||||
iterator = doc.createNodeIterator(parent)
|
iterator = doc.createNodeIterator(parent)
|
||||||
in_range = False
|
|
||||||
while True:
|
while True:
|
||||||
node = iterator.nextNode()
|
node = iterator.nextNode()
|
||||||
if not node:
|
if not node:
|
||||||
@ -44,7 +45,7 @@ def first_annot_in_range(r, annot_id_uuid_map):
|
|||||||
annot_id = annot_id_uuid_map[node.dataset.calibreRangeWrapper]
|
annot_id = annot_id_uuid_map[node.dataset.calibreRangeWrapper]
|
||||||
if annot_id:
|
if annot_id:
|
||||||
return annot_id
|
return annot_id
|
||||||
if node.isSameNode(r.endContainer):
|
if not is_full_tree and node.isSameNode(r.endContainer):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +53,8 @@ def all_annots_in_range(r, annot_id_uuid_map, ans):
|
|||||||
parent = r.commonAncestorContainer
|
parent = r.commonAncestorContainer
|
||||||
doc = parent.ownerDocument or document
|
doc = parent.ownerDocument or document
|
||||||
iterator = doc.createNodeIterator(parent)
|
iterator = doc.createNodeIterator(parent)
|
||||||
in_range = False
|
is_full_tree = parent is doc.documentElement
|
||||||
|
in_range = not is_full_tree
|
||||||
while True:
|
while True:
|
||||||
node = iterator.nextNode()
|
node = iterator.nextNode()
|
||||||
if not node:
|
if not node:
|
||||||
@ -64,7 +66,7 @@ def all_annots_in_range(r, annot_id_uuid_map, ans):
|
|||||||
annot_id = annot_id_uuid_map[node.dataset.calibreRangeWrapper]
|
annot_id = annot_id_uuid_map[node.dataset.calibreRangeWrapper]
|
||||||
if annot_id:
|
if annot_id:
|
||||||
ans.push(annot_id)
|
ans.push(annot_id)
|
||||||
if node.isSameNode(r.endContainer):
|
if not is_full_tree and node.isSameNode(r.endContainer):
|
||||||
break
|
break
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user