-
-
Notifications
You must be signed in to change notification settings - Fork 642
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
V2 of UI Automation in Windows Console: work around Microsoft bugs on Windows 10 version 1903 and improve caret movement #9802
V2 of UI Automation in Windows Console: work around Microsoft bugs on Windows 10 version 1903 and improve caret movement #9802
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've hade some nights sleep about this.
While it caused issues, I really liked the idea that editableText._hasCaretMoved processed caret events. How about something like this (would be good to know @michaelDCurran's pinion before starting on this).
- Below the
Caret events are unreliable in some controls.
comment, add something like this:
if self.detectCaretMovementUsingEvents and eventHandler.isPendingEvents("caret"):
log.debug("Caret move detected using event. Elapsed: %d ms" % elapsed)
return (True, newInfo)
Then, detectCaretMovementUsingEvents should be False by default, and only set to True for implementations where we are really sure that the textInfo doesn't lag behind.
@@ -187,6 +204,10 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo): | |||
min(end.value, max(1, len(lineText) - 2)) | |||
) | |||
|
|||
def __ne__(self,other): | |||
"""Support more accurate caret move detection.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does ne relate to caret move detection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain exactly what happens if you don't implement this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__ne__
is necessary as UIATextInfo has overridden __eq__```. So we want ```__ne__``` to return the opposite. This should really actually be on UIATextInfo itself, but this has caused strange bugs in the past, espcially in Edge. We are not sure why IUIAutomationTextRange.compare does not work correctly for some implementations. In consoles however, it does work okay. Note that in Python3 it will no longer be neceesary to provide a ```__ne__``` here as Python3 automatically implements ```__ne__
as the negative of __eq__
.
@@ -187,6 +204,10 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo): | |||
min(end.value, max(1, len(lineText) - 2)) | |||
) | |||
|
|||
def __ne__(self,other): | |||
"""Support more accurate caret move detection.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain exactly what happens if you don't implement this method?
|
Link to issue number:
Closes #9632 and #9649. Builds on #9614. Incorporates the
__ne__
method from #5991 for UIA consoletextInfo
s.Summary of the issue:
Currently:
collapse
method onconsoleUIATextInfo
is broken, resulting in several caret and selection bugs.Description of how this pull request fixes the issue:
consoleUIATextInfo.collapse
andconsoleUIATextInfo._get_isCollapsed
as suggested by @michaelDCurran.__ne__
method toconsoleUIATextInfo
to allow for better caret move detection._caretMovementTimeoutMultiplier
variable to editable text objects, and sets it to 1.5 for consoles (caret movement overssh
can be slowe).Note: unlike #9773, this PR does not depend on
caret
events (which caused #9786).Testing performed:
Tested the console on Windows 10 1903. Caret movement, selection, and backspace reporting are functional, even over
ssh
.Known issues with pull request:
Change log entry:
None.