Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ui Automation in Windows Console: fix _getTextLines for 21H1 #11760

Merged
merged 1 commit into from
Oct 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ def _getBoundingRange(self, obj, position):
if position == textInfos.POSITION_FIRST:
collapseToEnd = False
elif position == textInfos.POSITION_LAST:
# We must pull back the end by one character otherwise when we collapse to end,
# a console bug results in a textRange covering the entire console buffer!
# Strangely the *very* last character is a special blank point
# so we never seem to miss a real character.
# The exclusive end hangs off the end of the visible ranges.
# Move back one character to remain within bounds.
_rangeObj.MoveEndpointByUnit(
UIAHandler.TextPatternRangeEndpoint_End,
UIAHandler.NVDAUnitsToUIAUnits['character'],
Expand Down Expand Up @@ -366,13 +364,19 @@ def _get_TextInfo(self):
return consoleUIATextInfo if self.is21H1Plus else consoleUIATextInfoPre21H1

def _getTextLines(self):
if self.is21H1Plus:
# #11760: the 21H1 UIA console wraps across lines.
# When text wraps, NVDA starts reading from the beginning of the visible text for every new line of output.
# Use the superclass _getTextLines instead.
return super()._getTextLines()
# This override of _getTextLines takes advantage of the fact that
# the console text contains linefeeds for every line
# Thus a simple string splitlines is much faster than splitting by unit line.
ti = self.makeTextInfo(textInfos.POSITION_ALL)
text = ti.text or ""
return text.splitlines()


def detectPossibleSelectionChange(self):
try:
return super().detectPossibleSelectionChange()
Expand Down