From b92c233ad8683708c6b34c4f434e37145ec46329 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Apr 2020 16:40:22 +0530 Subject: [PATCH] Dont use an empty start selection to position handles --- src/pyj/read_book/create_annotation.pyj | 2 +- src/pyj/select.pyj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyj/read_book/create_annotation.pyj b/src/pyj/read_book/create_annotation.pyj index c4fe9adf7a..4d2fda7d42 100644 --- a/src/pyj/read_book/create_annotation.pyj +++ b/src/pyj/read_book/create_annotation.pyj @@ -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) diff --git a/src/pyj/select.pyj b/src/pyj/select.pyj index bcea829677..448a4047ee 100644 --- a/src/pyj/select.pyj +++ b/src/pyj/select.pyj @@ -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)