Skip to content

Commit

Permalink
Fix hanging during text paragraph navigation in UIA edge (#16450)
Browse files Browse the repository at this point in the history
Closes #16436.

Summary of the issue:
Text paragraph navigation hangs in UIA edge near the end of document.

Description of user facing changes
N/A

Description of development approach
Replaced logic to find next paragraph with already polished function from another PR. It's got a condition that prevents hanging in this case.
  • Loading branch information
mltony authored May 10, 2024
1 parent 2e51aa3 commit d19dea0
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions source/browseMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2547,17 +2547,7 @@ def _iterSimilarParagraph(
desiredValue = paragraphFunction(info)
for i in range(self.MAX_ITERATIONS_FOR_SIMILAR_PARAGRAPH):
# move by one paragraph in the desired direction
try:
info.collapse(end=direction == _Movement.NEXT)
except RuntimeError:
# Microsoft Word raises RuntimeError when collapsing textInfo to the last character of the document.
return

if direction == _Movement.PREVIOUS:
if info.move(textInfos.UNIT_CHARACTER, -1) == 0:
return
info.expand(textInfos.UNIT_PARAGRAPH)
if info.isCollapsed:
if not self._moveToNextParagraph(info, direction):
return
value = paragraphFunction(info)
if value == desiredValue:
Expand Down

0 comments on commit d19dea0

Please sign in to comment.