[PR #13250] Fix a11y crash in alt buffer apps #29443

Open
opened 2026-01-31 09:34:56 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13250

State: closed
Merged: Yes


Summary of the Pull Request

This fixes the crashes caused by using a screen reader when in an app that uses the alt buffer via two changes:

  1. Fix Terminal::ViewEndIndex()
    • UiaTextRangeBase receives a coordinate that is outside of the bounds of the text buffer via the following chain of functions... _getDocumentEnd() --> GetLastNonSpaceCharacter() --> _getOptimizedBufferSize() --> GetTextBufferEndPoisition() --> ViewEndIndex()
    • Since support for the alt buffer was added recently, ViewEndIndex() was recently changed, so that explains why this issue came up recently. We were accidentally setting the view end index to height instead of height-1. Thanks @j4james for finding this!
    • The UIA code would get the "exclusive end" of the alt buffer. Since it was using ViewEndIndex() to calculate that, it was one more than it should be. The UIA code has explicit allowance for "one past the end of the viewport" in its IsInBounds() check. Since the ViewEndIndex() is way beyond that, it's not allowed, hitting the fail fast.
  2. Replace FAIL_FAST_IF with assert
    • These fail fast calls have caused so many issues with our UIA code. Those checks still provide value, but they shouldn't take the whole app down. This change replaces the Viewport and UiaTextRangeBase fail fasts with asserts to still perform those checks, but not take down the entire app in release builds.

Closes #13183

Validation Steps Performed

While using Narrator...

  • opened nano in bash
  • generated text and scrolled in nano
  • generated text and scrolled in PowerShell
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13250 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This fixes the crashes caused by using a screen reader when in an app that uses the alt buffer via two changes: 1. Fix `Terminal::ViewEndIndex()` - `UiaTextRangeBase` receives a coordinate that is outside of the bounds of the text buffer via the following chain of functions... `_getDocumentEnd()` --> `GetLastNonSpaceCharacter()` --> `_getOptimizedBufferSize()` --> `GetTextBufferEndPoisition()` --> `ViewEndIndex()` - Since support for the alt buffer was added recently, `ViewEndIndex()` was recently changed, so that explains why this issue came up recently. We were accidentally setting the view end index to `height` instead of `height-1`. Thanks @j4james for finding this! - The UIA code would get the "exclusive end" of the alt buffer. Since it was using `ViewEndIndex()` to calculate that, it was one more than it should be. The UIA code has explicit allowance for "one past the end of the viewport" in its `IsInBounds()` check. Since the `ViewEndIndex()` is way beyond that, it's not allowed, hitting the fail fast. 2. Replace `FAIL_FAST_IF` with `assert` - These fail fast calls have caused so many issues with our UIA code. Those checks still provide value, but they shouldn't take the whole app down. This change replaces the `Viewport` and `UiaTextRangeBase` fail fasts with asserts to still perform those checks, but not take down the entire app in release builds. Closes #13183 ## Validation Steps Performed While using Narrator... - opened nano in bash - generated text and scrolled in nano - generated text and scrolled in PowerShell
claunia added the pull-request label 2026-01-31 09:34:56 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29443