|
| 1 | +# -*- coding: UTF-8 -*- |
1 | 2 | #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 |
3 | 4 | #This file is covered by the GNU General Public License. |
4 | 5 | #See the file COPYING for more details. |
5 | 6 |
|
|
42 | 43 | SCI_POSITIONFROMLINE=2167 |
43 | 44 | SCI_LINELENGTH=2350 |
44 | 45 | SCI_GETSTYLEAT=2010 |
| 46 | +SCI_GETCHARAT=2007 |
45 | 47 | SCI_STYLEGETFONT=2486 |
46 | 48 | SCI_STYLEGETSIZE=2485 |
47 | 49 | SCI_STYLEGETBOLD=2483 |
|
59 | 61 | INVALID_POSITION=-1 |
60 | 62 | STYLE_DEFAULT=32 |
61 | 63 | SC_CP_UTF8=65001 |
| 64 | +space=32 |
62 | 65 |
|
63 | 66 | class CharacterRangeStruct(ctypes.Structure): |
64 | 67 | _fields_=[ |
@@ -195,6 +198,12 @@ def _getWordOffsets(self,offset): |
195 | 198 | if end<=offset: |
196 | 199 | start=end |
197 | 200 | 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) |
198 | 207 | return [start,end] |
199 | 208 |
|
200 | 209 | def _getLineNumFromOffset(self,offset): |
|
0 commit comments