Skip to content

Commit

Permalink
UIA with conhost / openconsole on Win 21H1 comError (PR nvaccess#11039)
Browse files Browse the repository at this point in the history
Downgrade E_FAIL to debugWarning when comparing selection changes.
  • Loading branch information
codeofdusk authored Oct 12, 2020
1 parent 7f9a12a commit e274931
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import UIAHandler

from comtypes import COMError
from UIAUtils import isTextRangeOffscreen
from logHandler import log
from . import UIATextInfo
from ..behaviors import EnhancedTermTypedCharSupport, KeyboardHandlerBasedTypedCharSupport
from ..window import Window
Expand All @@ -31,7 +31,6 @@ def __init__(self, obj, position, _rangeObj=None):
_rangeObj, collapseToEnd = self._getBoundingRange(obj, position)
except (COMError, RuntimeError):
# We couldn't bound the console.
from logHandler import log
log.warning("Couldn't get bounding range for console", exc_info=True)
# Fall back to presenting the entire buffer.
_rangeObj, collapseToEnd = None, None
Expand Down Expand Up @@ -374,6 +373,19 @@ def _getTextLines(self):
text = ti.text or ""
return text.splitlines()

def detectPossibleSelectionChange(self):
try:
return super().detectPossibleSelectionChange()
except COMError:
# microsoft/terminal#5399: when attempting to compare text ranges
# from the standard and alt mode buffers, E_FAIL is returned.
# Downgrade this to a debugWarning.
log.debugWarning((
"Exception raised when comparing selections, "
"probably due to a switch to/from the alt buffer."
), exc_info=True)


def findExtraOverlayClasses(obj, clsList):
if obj.UIAElement.cachedAutomationId == "Text Area":
clsList.append(WinConsoleUIA)
Expand Down

0 comments on commit e274931

Please sign in to comment.