Skip to content

Commit ad7016e

Browse files
authored
Merge 9dfd9c5 into 1af8775
2 parents 1af8775 + 9dfd9c5 commit ad7016e

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

source/NVDAObjects/window/scintilla.py

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

67
import ctypes
78
import IAccessibleHandler
@@ -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)