mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround chromium causing selection start to also change when end is changed in some circumstances
Fixes #2054934 [Extra text copied when selecting across pages](https://bugs.launchpad.net/calibre/+bug/2054934)
This commit is contained in:
parent
2e4b88059c
commit
b10eebf7a0
@ -228,13 +228,15 @@ def move_end_of_selection(pos, start):
|
|||||||
else:
|
else:
|
||||||
# point is inside the selection
|
# point is inside the selection
|
||||||
start = False
|
start = False
|
||||||
|
new_range = document.createRange()
|
||||||
if start:
|
if start:
|
||||||
if r.startContainer is not p.offsetNode or r.startOffset is not p.offset:
|
new_range.setStart(p.offsetNode, p.offset)
|
||||||
r.setStart(p.offsetNode, p.offset)
|
new_range.setEnd(r.endContainer, r.endOffset)
|
||||||
sel.removeAllRanges()
|
other_boundary_changed = r.endContainer is not new_range.endContainer or r.endOffset is not new_range.endOffset
|
||||||
sel.addRange(r)
|
|
||||||
else:
|
else:
|
||||||
if r.endContainer is not p.offsetNode or r.endOffset is not p.offset:
|
new_range.setStart(r.startContainer, r.startOffset)
|
||||||
r.setEnd(p.offsetNode, p.offset)
|
new_range.setEnd(p.offsetNode, p.offset)
|
||||||
|
other_boundary_changed = r.startContainer is not new_range.startContainer or r.startOffset is not new_range.startOffset
|
||||||
|
if not new_range.collapsed or not other_boundary_changed:
|
||||||
sel.removeAllRanges()
|
sel.removeAllRanges()
|
||||||
sel.addRange(r)
|
sel.addRange(new_range)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user