[PR #10991] Fix failing UIA movement tests #28349

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Follow-up for #10886. The new UIA movement tests found some failing cases. This PR fixes UiaTextRangeBase to have movement match that of MS Word. In total, this fixes 64 tests.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Root causes include...

  1. if we were a non-degenerate range and we failed to move, we should still expand to enclose the unit
  2. non-degenerate ranges are treated as if they already encompassed their given unit.
    • this one is a bit difficult to explain. Consider these examples:
      1. document movement
        • state: you have a 1-cell wide range on the buffer, and you try to move by document
        • result: move by 0 (there is no next/prev document), but the range now encompasses the entire document
      2. line movement
        • state: you have a 1-cell wide range on a line, and you try to move back by a line
        • result: you go to the previous line (not the beginning of this line)
    • conversely, a degenerate range successfully moves to the beginning/end of the current unit (i.e. document/line)
    • this (bizarre) behavior was confirmed using MS Word

As a bonus, occasionally, Narrator would get stuck when navigating by line. This issue now seems to be fixed.

Updates to existing tests

  • CanMoveByCharacter
    • can't move backward from (0, 0) --> misauthored, result should be one character wide.
    • can't move past the last column in the last row --> misauthored and already covered in generated tests
  • CanMoveByLine
    • can't move backward from top row --> misauthored, end should be on next line. Already covered by generated tests
    • can't move forward from bottom row --> misauthored, end should be on next line
    • can't move backward when part of the top row is in the range --> misauthored, should expand
    • can't move forward when part of the bottom row is in the range --> misauthored, degenerate range moves to end of buffer
  • MovementAtExclusiveEnd
    • populate the text buffer before we do a move by word operation
    • update to match the now fixed behavior
**Original Pull Request:** https://github.com/microsoft/terminal/pull/10991 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Follow-up for #10886. The new UIA movement tests found some failing cases. This PR fixes UiaTextRangeBase to have movement match that of MS Word. In total, this fixes 64 tests. ## PR Checklist * [X] Closes #10924 * [X] Tests added/passed ## Detailed Description of the Pull Request / Additional comments Root causes include... 1. if we were a non-degenerate range and we failed to move, we should still expand to enclose the unit 2. non-degenerate ranges are treated as if they already encompassed their given unit. - this one is a bit difficult to explain. Consider these examples: 1. document movement - state: you have a 1-cell wide range on the buffer, and you try to move by document - result: move by 0 (there is no next/prev document), but the range now encompasses the entire document 2. line movement - state: you have a 1-cell wide range on a line, and you try to move back by a line - result: you go to the previous line (not the beginning of this line) - conversely, a degenerate range successfully moves to the beginning/end of the current unit (i.e. document/line) - this (bizarre) behavior was confirmed using MS Word As a bonus, occasionally, Narrator would get stuck when navigating by line. This issue now seems to be fixed. ## Updates to existing tests - `CanMoveByCharacter` - `can't move backward from (0, 0)` --> misauthored, result should be one character wide. - `can't move past the last column in the last row` --> misauthored and already covered in generated tests - `CanMoveByLine` - `can't move backward from top row` --> misauthored, end should be on next line. Already covered by generated tests - `can't move forward from bottom row` --> misauthored, end should be on next line - `can't move backward when part of the top row is in the range` --> misauthored, should expand - `can't move forward when part of the bottom row is in the range` --> misauthored, degenerate range moves to end of buffer - `MovementAtExclusiveEnd` - populate the text buffer _before_ we do a move by word operation - update to match the now fixed behavior
claunia added the pull-request label 2026-01-31 09:27: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#28349