nvda icon indicating copy to clipboard operation
nvda copied to clipboard

Fix exception during textInfos.moveToCodepointOffset when some characters correspond to 0 pythonic characters

Open mltony opened this issue 10 months ago • 0 comments

Link to issue number:

Partially closes #16406.

Summary of the issue:

When trying to navigate by style an exception is thrown:

RuntimeError: Unable to find desired offset in TextInfo.

Description of user facing changes

N/A

Description of development approach

Investigation showed that in Outlook with word UIA enabled, sometimes there are characters that translate into 0 codepoint characters. To illustrate this further:

>>> p=focus.treeInterceptor.makeTextInfo('caret')
>>> p.expand('paragraph')
>>> p.text
'View in browser'
>>> p.collapse(end=True)
>>> p.move('character', -1, 'start')
-1
>>> p.text
''
>>> len(p.text)
0

E.g. we move a collapsed text info start by -1 character, and the resulting textInfo still appears to be empty- at least its Python text is empty. I anticipated this to happen somewhere, but didn't encounter a single example when I was implementing moveToCodepointOffset function, so I missed one edge case. Now fixing this edge case. Also adding unit tests.

Testing strategy:

Unit test. Tested on test case from the original issue with UIA enabled.

Known issues with pull request:

N/A

Code Review Checklist:

  • [x] Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • [x] Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • [x] UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • [x] API is compatible with existing add-ons.
  • [x] Security precautions taken.

mltony avatar Apr 25 '24 00:04 mltony