[PR #17695] Fix UIA RangeFromPoint API #31324

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Fixes the RangeFromPoint API such that we're now properly locking when we attempt to retrieve the viewport data. This also corrects the conversion from UiaPoint (screen position) to buffer coordinates (buffer cell).

Closes #17579

Detailed Description of the Pull Request / Additional comments

  • UiaTextRangeBase::Initialize(UiaPoint):
    • reordered logic to clamp to client area first, then begin conversion to buffer coordinates
    • properly lock when retrieving the viewport data
  • updated _TranslatePointToScreen and _TranslatePointFromScreen to use & instead of *
    • we weren't properly updating the parameter before
  • TermControlUiaTextRange::_TranslatePointFromScreen()
    • includeOffsets was basically copied over from _TranslatePointToScreen. The math itself was straight up wrong since we had to do it backwards.

Validation Steps Performed

Moved WT to top-left of monitor, then used inspect.exe to call RangeFromPoint API when mouse cursor is on top-left buffer cell (also meticulously stepped through the two functions ensuring everything was correct).

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17695 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Fixes the `RangeFromPoint` API such that we're now properly locking when we attempt to retrieve the viewport data. This also corrects the conversion from `UiaPoint` (screen position) to buffer coordinates (buffer cell). Closes #17579 ## Detailed Description of the Pull Request / Additional comments - `UiaTextRangeBase::Initialize(UiaPoint)`: - reordered logic to clamp to client area first, then begin conversion to buffer coordinates - properly lock when retrieving the viewport data - updated `_TranslatePointToScreen` and `_TranslatePointFromScreen` to use `&` instead of `*` - we weren't properly updating the parameter before - `TermControlUiaTextRange::_TranslatePointFromScreen()` - `includeOffsets` was basically copied over from `_TranslatePointToScreen`. The math itself was straight up wrong since we had to do it backwards. ## Validation Steps Performed ✅ Moved WT to top-left of monitor, then used inspect.exe to call `RangeFromPoint` API when mouse cursor is on top-left buffer cell (also meticulously stepped through the two functions ensuring everything was correct).
claunia added the pull-request label 2026-01-31 09:46:35 +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#31324