Skip to content

Commit

Permalink
Use OffsetConverter for OffsetTextInfo find (#16657)
Browse files Browse the repository at this point in the history
Fixes #16317

Summary of the issue:
Find in browse mode (Virtual Buffers) can be inaccurate when a python character spans two character offsets in the underlying TextInfo, such as when emojis come in to play.

Description of user facing changes
Find functionality is now accurate when a page contains emoji characters and similar.

Description of development approach
Use an OffsetConverter to correct offsets.
  • Loading branch information
LeonarddeR authored Jun 6, 2024
1 parent ebee59b commit c124435
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/textInfos/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,11 @@ def find(self,text,caseSensitive=False,reverse=False):
m=re.search(re.escape(text),inText,(0 if caseSensitive else re.IGNORECASE)|re.UNICODE)
if not m:
return False
converter = textUtils.getOffsetConverter(self.encoding)(inText)
if reverse:
offset=self._startOffset-m.end()
offset = self._startOffset - converter.strToEncodedOffsets(m.end())
else:
offset=self._startOffset+1+m.start()
offset = self._startOffset + 1 + converter.strToEncodedOffsets(m.start())
self._startOffset=self._endOffset=offset
return True

Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Unicode CLDR has been updated.
* Error messages referenced with `aria-errormessage` are now reported in Google Chrome and Mozilla Firefox. (#8318)
* If present, NVDA will now use `aria-labelledby` to provide accessible names for tables in Mozilla Firefox. (#5183)
* NVDA will correctly announce radio and checkbox menuitems when first entering submenus in Google Chrome and Mozilla Firefox. (#14550)
* NVDA's browse mode find functionality is now more accurate when the page contains emojis. (#16317, @LeonarddeR)
* NVDA will announce correctly the autocomplete suggestions in Eclipse and other Eclipse-based environments on Windows 11. (#16416, @thgcode)
* Improved reliability of automatic text readout, particularly in terminal applications. (#15850, #16027, @Danstiv)
* NVDA will correctly announce selection changes when editing a cell's text in Microsoft Excel. (#15843)
Expand Down

0 comments on commit c124435

Please sign in to comment.