[PR #12436] Validate cursor position in UIA UTR ctor #29038

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

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

State: closed
Merged: Yes


Summary of the Pull Request

This adds some validation in the UiaTextRange ctor for the cursor position.

#8730 was caused by creating a UiaTextRange at the cursor position when it was in a delayed state (meaning it's purposefully hanging off of the right edge of the buffer). Normally, Cursor maintains a flag to keep track of when that occurs, but Windows Terminal isn't maintaining that properly in Terminal::WriteBuffer.

The correct approach would be to fix WriteBuffer then leverage that flag for validation in UiaTextRange. However, messing with WriteBuffer is a little too risky for our comfort right now. So we'll do the second half of that by checking if the cursor position is valid. Since the cursor is really only expected to be out of bounds when it's in that delayed state, we get the same result (just maybe a tad slower than simply checking a flag).

Closes #8730

Filed #12440 to track changes in Terminal::_WriteBuffer for delayed EOL wrap.

Validation Steps Performed

While using magnifier, input/delete wrapped text in input buffer.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/12436 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This adds some validation in the `UiaTextRange` ctor for the cursor position. #8730 was caused by creating a `UiaTextRange` at the cursor position when it was in a delayed state (meaning it's purposefully hanging off of the right edge of the buffer). Normally, `Cursor` maintains a flag to keep track of when that occurs, but Windows Terminal isn't maintaining that properly in `Terminal::WriteBuffer`. The _correct_ approach would be to fix `WriteBuffer` then leverage that flag for validation in `UiaTextRange`. However, messing with `WriteBuffer` is a little too risky for our comfort right now. So we'll do the second half of that by checking if the cursor position is valid. Since the cursor is really only expected to be out of bounds when it's in that delayed state, we get the same result (just maybe a tad slower than simply checking a flag). Closes #8730 Filed #12440 to track changes in `Terminal::_WriteBuffer` for delayed EOL wrap. ## Validation Steps Performed While using magnifier, input/delete wrapped text in input buffer.
claunia added the pull-request label 2026-01-31 09:32:23 +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#29038