Skip to content

Commit 2a7a736

Browse files
authored
Merge af105cb into 83d7233
2 parents 83d7233 + af105cb commit 2a7a736

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

source/NVDAObjects/window/scintilla.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# -*- coding: UTF-8 -*-
12
#A part of NonVisual Desktop Access (NVDA)
2-
#Copyright (C) 2009-2019 NV Access Limited, Arnold Loubriat, Babbage B.V.
3+
#Copyright (C) 2009-2019 NV Access Limited, Arnold Loubriat, Babbage B.V., Łukasz Golonka
34
#This file is covered by the GNU General Public License.
45
#See the file COPYING for more details.
56

@@ -42,6 +43,7 @@
4243
SCI_POSITIONFROMLINE=2167
4344
SCI_LINELENGTH=2350
4445
SCI_GETSTYLEAT=2010
46+
SCI_GETCHARAT=2007
4547
SCI_STYLEGETFONT=2486
4648
SCI_STYLEGETSIZE=2485
4749
SCI_STYLEGETBOLD=2483
@@ -59,6 +61,7 @@
5961
INVALID_POSITION=-1
6062
STYLE_DEFAULT=32
6163
SC_CP_UTF8=65001
64+
space=32
6265

6366
class CharacterRangeStruct(ctypes.Structure):
6467
_fields_=[
@@ -195,6 +198,12 @@ def _getWordOffsets(self,offset):
195198
if end<=offset:
196199
start=end
197200
end=watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_WORDENDPOSITION,offset,0)
201+
# #8295: When calculating offsets with Scintilla messages spaces are considered to be words.
202+
#Therefore check if character at offset is a space, and if so calculate it again.
203+
if watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_GETCHARAT,end,0)==space:
204+
end=watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_WORDENDPOSITION,end,0)
205+
if watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_GETCHARAT,start,0)==space:
206+
start=watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_WORDSTARTPOSITION,start,0)
198207
return [start,end]
199208

200209
def _getLineNumFromOffset(self,offset):

0 commit comments

Comments
 (0)