Dont use an empty start selection to position handles

This commit is contained in:
Kovid Goyal 2020-04-13 16:40:22 +05:30
parent b40951e5dc
commit b92c233ad8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 2 deletions

View File

@ -435,7 +435,7 @@ class CreateAnnotation:
self.state = WAITING_FOR_CLICK
self.show()
self.hide_handles()
if msg.extents.start.x is not None:
if msg.extents and msg.extents.start.x is not None:
self.place_handles(msg.extents)
self.in_flow_mode = msg.in_flow_mode
self.send_message('set-highlight-style', style=self.current_highlight_style)

View File

@ -75,7 +75,7 @@ def range_extents(start, end, in_flow_mode):
def selection_extents(in_flow_mode):
sel = window.getSelection()
if not sel or not sel.rangeCount:
if not sel or not sel.rangeCount or sel.isCollapsed:
return range_extents()
start = sel.getRangeAt(0)
end = sel.getRangeAt(sel.rangeCount - 1)