Expicitly mark is selection extent was found or not

This commit is contained in:
Kovid Goyal 2020-07-23 21:27:20 +05:30
parent 9f4609aec2
commit 0c233efa27
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 3 deletions

View File

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

View File

@ -46,8 +46,8 @@ def word_at_point(x, y):
def empty_range_extents(): def empty_range_extents():
return { return {
'start': {'x': 0, 'y': 0, 'height': 0, 'onscreen': False}, 'start': {'x': 0, 'y': 0, 'height': 0, 'onscreen': False, 'is_empty': True},
'end': {'x': 0, 'y': 0, 'height': 0, 'onscreen': False} 'end': {'x': 0, 'y': 0, 'height': 0, 'onscreen': False, 'is_empty': True}
} }
@ -78,6 +78,8 @@ def range_extents(start, end, in_flow_mode):
for_boundary(start, ans.start) for_boundary(start, ans.start)
for_boundary(end, ans.end) for_boundary(end, ans.end)
ans.start.is_empty = ans.start.height > 0
ans.end.is_empty = ans.end.height > 0
return ans return ans
@ -112,6 +114,7 @@ def selection_extents_at_point(x, y, in_flow_mode):
ans.start.x = x ans.start.x = x
ans.end.x = x + ans.start.height * 3 ans.end.x = x + ans.start.height * 3
ans.start.onscreen = ans.end.onscreen = True ans.start.onscreen = ans.end.onscreen = True
ans.start.is_empty = ans.end.is_empty = False
return ans return ans