Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Automation in Windows Console: fix setEndPoint/compareEndPoints #10043

Closed

Conversation

codeofdusk
Copy link
Contributor

Link to issue number:

Closes #10035. Related to #9614.

Summary of the issue:

Braille does not properly track the system caret in Windows Console.

Description of how this pull request fixes the issue:

#9802 introduced a patched implementation of _get_isCollapsed. As suggested by @LeonarddeR, this code has been factored out into a new _endPointHelper method which normalizes endPoints for compareEndPoints and setEndPoint (used by _get_isCollapsed, Braille support, and possibly others).

Testing performed:

Tested that the isCollapsed property behaves as expected (in the Python console). Testing by @LeonarddeR indicates that Braille behaves as expected after the change.

Known issues with pull request:

None.

Change log entry:

None.

@codeofdusk
Copy link
Contributor Author

Cc @feerrenrut @LeonarddeR

@LeonarddeR LeonarddeR requested a review from feerrenrut August 6, 2019 17:42
@LeonarddeR
Copy link
Collaborator

I see why you brought back isCollapsed. I have a small concern though.

  1. The base TextInfo implementation of TextInfo.isCollapsed calls compareEndPoints
  2. Now. your implementation of compareEndPoints indirectly calls is Collapsed.
  3. If the implementation of isCollapsed ever calls super, this causes an endless loop. Currently it does not, but I see why it at some point would if Microsoft fixes things in the UIA implementation.

I think it makes sense to rename _get_isCollapsed to _get_isEmpty. endPointHelper can get ifEmpty and isCollapsed can just return it.

@codeofdusk
Copy link
Contributor Author

Closing to possibly work around a Github bug. Identical PR pending.

@feerrenrut
Copy link
Contributor

This PR does not seem to be updating from the source branch, it is missing commit
5544ede. See diff between master and source branch: master...codeofdusk:cmduia10-fix-compareendpoints

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Aug 8, 2019 via email

@feerrenrut
Copy link
Contributor

@LeonarddeR, Bill opened a new PR at my request. I wanted to preserve the state of this PR for the Github bug report. I hadn't considered that opening a new PR would close this one.

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Aug 8, 2019 via email

feerrenrut pushed a commit that referenced this pull request Aug 12, 2019
Closes #10035
Related to #9614
Identical to #10043

Works around a UIA bug on Windows 10 1803 and later that means we can
not trust the "end" endpoint of a collapsed (empty) text range for comparisons. 
The console incorrectly reports the "end" as being past the "start" endpoint.

This stops braille being able to properly track the system caret in Windows Console.

Instead use getText(1) on the textRange to attempt to fetch 1 character.
getText returns an empty string for a collapsed range. By definition, the "start" and
"end" endpoints for a collapsed range are equivalent, thus read from the "start"
endpoint of a collapsed range instead of the "end" endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UIA in Windows consoles: current character does not show up in braille
3 participants