Skip to content

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

Closed
codeofdusk wants to merge 7 commits into
nvaccess:masterfrom
codeofdusk:cmduia10-fix-compareendpoints
Closed

UI Automation in Windows Console: fix setEndPoint/compareEndPoints#10043
codeofdusk wants to merge 7 commits into
nvaccess:masterfrom
codeofdusk:cmduia10-fix-compareendpoints

Conversation

@codeofdusk

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Cc @feerrenrut @LeonarddeR

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@feerrenrut

Copy link
Copy Markdown
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

LeonarddeR commented Aug 8, 2019 via email

Copy link
Copy Markdown
Collaborator

@feerrenrut

Copy link
Copy Markdown
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

LeonarddeR commented Aug 8, 2019 via email

Copy link
Copy Markdown
Collaborator

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