UIA: degenerate text ranges not degenerate after move #10221

Closed
opened 2026-01-31 02:15:40 +00:00 by claunia · 5 comments
Owner

Originally created by @codeofdusk on GitHub (Aug 19, 2020).

Originally assigned to: @carlos-zamora on GitHub.

Environment

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] Latest master of OpenConsole
Windows Terminal version (if applicable):

Any other software? NVDA

Steps to reproduce

>>> # In the NVDA Python console (NVDA+control+z)
>>> # In a Microsoft Word document (using UIA for access, enable in advanced settings), caret positioned on the first "C" in "Cactus".
>>> start = nav.makeTextInfo("caret")
>>> end = start.copy()
>>> end.move("character", 2) # move to the second "c".
2
>>> marker=start.copy()
>>> marker.setEndPoint(start, "startToStart") # Calls MoveEndpointByRange for UIA controls.
>>> marker.setEndPoint(end, "endToEnd")
>>> marker.text
'Ca' # GOOD

>>> # Now, in conhost with UIA enabled
>>> start = nav.makeTextInfo("caret")
>>> end = start.copy()
>>> end.move("character", 2)
2
>>> marker=start.copy()
>>> marker.setEndPoint(start, "startToStart")
>>> marker.setEndPoint(end, "endToEnd")
>>> marker.text
'Cac' # BAD

Expected behaviour

Conhost matches Microsoft Word when calling MoveEndpointByRange.

Actual behaviour

See above.

Originally created by @codeofdusk on GitHub (Aug 19, 2020). Originally assigned to: @carlos-zamora on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] Latest master of OpenConsole Windows Terminal version (if applicable): Any other software? NVDA ``` # Steps to reproduce ```Python console >>> # In the NVDA Python console (NVDA+control+z) >>> # In a Microsoft Word document (using UIA for access, enable in advanced settings), caret positioned on the first "C" in "Cactus". >>> start = nav.makeTextInfo("caret") >>> end = start.copy() >>> end.move("character", 2) # move to the second "c". 2 >>> marker=start.copy() >>> marker.setEndPoint(start, "startToStart") # Calls MoveEndpointByRange for UIA controls. >>> marker.setEndPoint(end, "endToEnd") >>> marker.text 'Ca' # GOOD >>> # Now, in conhost with UIA enabled >>> start = nav.makeTextInfo("caret") >>> end = start.copy() >>> end.move("character", 2) 2 >>> marker=start.copy() >>> marker.setEndPoint(start, "startToStart") >>> marker.setEndPoint(end, "endToEnd") >>> marker.text 'Cac' # BAD ``` # Expected behaviour Conhost matches Microsoft Word when calling `MoveEndpointByRange`. <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> # Actual behaviour See above. <!-- What's actually happening? -->
Author
Owner

@codeofdusk commented on GitHub (Aug 19, 2020):

Cc @carlos-zamora.

@codeofdusk commented on GitHub (Aug 19, 2020): Cc @carlos-zamora.
Author
Owner

@codeofdusk commented on GitHub (Aug 20, 2020):

Could this please be reconsidered for 21H1? I'd really like to start using UIA console by default. Thanks.

@codeofdusk commented on GitHub (Aug 20, 2020): Could this please be reconsidered for 21H1? I'd really like to start using UIA console by default. Thanks.
Author
Owner

@codeofdusk commented on GitHub (Sep 3, 2020):

The issue seems not to be with MoveEndpointByRange after all, but rather with move. It calls ExpandToEnclosingUnit to determine _end, but I don't think that's quite right. See, for example:

>>> # In word
>>> ti=nav.makeTextInfo("caret")
>>> ti.compareEndPoints(ti, "startToEnd")
0
>>> ti.move("character", 2)
2
>>> ti.compareEndPoints(ti, "startToEnd")
0
>>> # Now, in conhost
>>> ti=nav.makeTextInfo("caret")
>>> ti.compareEndPoints(ti, "startToEnd")
0
>>> ti.move("character", 2)
2
>>> ti.compareEndPoints(ti, "startToEnd")
-1

Based on my testing in Word, the key seems to be: if a degenerate range is moved, it should remain degenerate after the move.

@codeofdusk commented on GitHub (Sep 3, 2020): The issue seems not to be with `MoveEndpointByRange` after all, but rather with `move`. It calls `ExpandToEnclosingUnit` to determine `_end`, but I don't think that's quite right. See, for example: ```python console >>> # In word >>> ti=nav.makeTextInfo("caret") >>> ti.compareEndPoints(ti, "startToEnd") 0 >>> ti.move("character", 2) 2 >>> ti.compareEndPoints(ti, "startToEnd") 0 >>> # Now, in conhost >>> ti=nav.makeTextInfo("caret") >>> ti.compareEndPoints(ti, "startToEnd") 0 >>> ti.move("character", 2) 2 >>> ti.compareEndPoints(ti, "startToEnd") -1 ``` Based on my testing in Word, the key seems to be: if a degenerate range is moved, it should remain degenerate after the move.
Author
Owner

@ghost commented on GitHub (Sep 22, 2020):

:tada:This issue was addressed in #7530, which has now been successfully released as Windows Terminal v1.3.2651.0.🎉

Handy links:

@ghost commented on GitHub (Sep 22, 2020): :tada:This issue was addressed in #7530, which has now been successfully released as `Windows Terminal v1.3.2651.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.3.2651.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Sep 22, 2020):

:tada:This issue was addressed in #7530, which has now been successfully released as Windows Terminal Preview v1.4.2652.0.🎉

Handy links:

@ghost commented on GitHub (Sep 22, 2020): :tada:This issue was addressed in #7530, which has now been successfully released as `Windows Terminal Preview v1.4.2652.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.4.2652.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10221