Repository: nvaccess/nvda

Issue:
Python 2 and Python 3: in poedit, when reading mixture of the english and devanagari text in listview, not allowed screen coordinates are present
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
1. Open the nvda.po (hindi language translation in the poedit, preferably from SRT),
2. find the string which says "no audio ducking"

### Actual behavior:
the error tone is reproduced, and nvda reports not selected
in the log we see the following error:

```
ERROR - scriptHandler.executeScript (15:45:42.647):
error executing script: <bound method GlobalCommands.script_review_previousCharacter of <globalCommands.GlobalCommands object at 0x0592E070>> with gesture '1 на цифровом блоке'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 190, in executeScript
  File "globalCommands.pyc", line 1112, in script_review_previousCharacter
  File "textInfos\offsets.pyc", line 470, in expand
  File "textInfos\offsets.pyc", line 449, in _getUnitOffsets
  File "textInfos\offsets.pyc", line 357, in _getLineOffsets
  File "NVDAObjects\__init__.pyc", line 45, in _getStoryText
  File "baseObject.pyc", line 46, in __get__
  File "baseObject.pyc", line 149, in _getPropertyViaCache
  File "NVDAObjects\__init__.pyc", line 1103, in _get_basicText
  File "baseObject.pyc", line 46, in __get__
  File "baseObject.pyc", line 149, in _getPropertyViaCache
  File "appModules\poedit.pyc", line 149, in _get_name
  File "baseObject.pyc", line 46, in __get__
  File "baseObject.pyc", line 149, in _getPropertyViaCache
  File "appModules\poedit.pyc", line 137, in _get_isBold
  File "textInfos\offsets.pyc", line 470, in expand
  File "textInfos\offsets.pyc", line 449, in _getUnitOffsets
  File "textInfos\offsets.pyc", line 306, in _getCharacterOffsets
  File "displayModel.pyc", line 460, in _getLineOffsets
  File "baseObject.pyc", line 46, in __get__
  File "baseObject.pyc", line 149, in _getPropertyViaCache
  File "displayModel.pyc", line 286, in _get__storyFieldsAndRects
  File "displayModel.pyc", line 184, in getWindowTextInRect
  File "locationHelper.pyc", line 398, in __new__
ValueError: left=655 is greather than right=654, which is not allowed
```

### Expected behavior:
the string along with its translation should be read. It can be also critical for displaying NVDA in hindi or other devanagari based language.

### System configuration

#### NVDA installed/portable/running from source:
tested on the portable and installed versions of nvda, py2 and 3 based

#### NVDA version:
latest py2 alpha snapshot and py3 treshold

#### Windows version:
windows 10 1903, 1with latest ssu and lsu

#### Name and version of other software in use when reproducing the issue:
poedit 1.6.10, the most accessible version in which the app module works

#### Other information about your system:
n/a

### Other questions

#### Does the issue still occur after restarting your PC?
yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
latest alpha, behaving as stated above. 


Discussion:
I can reproduce this indeed.

Resolving patch:
diff --git a/source/displayModel.py b/source/displayModel.py
--- a/source/displayModel.py
+++ b/source/displayModel.py
@@ -200,7 +200,15 @@ def getWindowTextInRect(bindingHandle, windowHandle, left, top, right, bottom,mi
 	characterLocations = []
 	cpBufIt = iter(cpBuf)
 	for cp in cpBufIt:
-		characterLocations.append(RectLTRB(wcharToInt(cp), wcharToInt(next(cpBufIt)), wcharToInt(next(cpBufIt)), wcharToInt(next(cpBufIt))))
+		left, top, right, bottom = (
+			wcharToInt(cp),
+			wcharToInt(next(cpBufIt)),
+			wcharToInt(next(cpBufIt)),
+			wcharToInt(next(cpBufIt))
+		)
+		if right < left:
+			left, right = right, left
+		characterLocations.append(RectLTRB(left, top, right, bottom))
 	return text, characterLocations
 
 def getFocusRect(obj):


Test patch: