Update magnifier Point at start#19780
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes magnifier caret-follow failures when the caret is positioned at end-of-text by improving how OffsetsTextInfo.pointAtStart is computed when the current offset can’t be mapped to screen coordinates.
Changes:
- Extend
_get_pointAtStartto handleLookupErroras well asNotImplementedErrorwhen resolving a point for the current offset. - Add a fallback for collapsed ranges to use the previous character’s offset when the caret is at end-of-text and current-offset location lookup fails.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I am not an expert of this code. But I wonder if it would not be better, if possible, to implement the fallback in magnifier files rather than in |
|
I think I agree with @CyrilleB79 here. |
|
Is this ready for re-review? |
…fix/NVDAPythonConsole
| if not (isinstance(textInfo, OffsetsTextInfo) and textInfo.isCollapsed and textInfo._startOffset > 0): | ||
| raise originalExc |
There was a problem hiding this comment.
I think it would be cleaner to just indent this into the except block. It will make reading the logs when it's raised more obvious too
| return textInfo.pointAtStart | ||
| except (NotImplementedError, LookupError, AttributeError): | ||
| pass | ||
| except (NotImplementedError, LookupError, AttributeError) as e: |
| try: | ||
| return textInfo._getPointFromOffset(prevOffset) | ||
| except (NotImplementedError, LookupError, AttributeError): | ||
| pass | ||
| raise originalExc |
There was a problem hiding this comment.
| try: | |
| return textInfo._getPointFromOffset(prevOffset) | |
| except (NotImplementedError, LookupError, AttributeError): | |
| pass | |
| raise originalExc | |
| log.debug(...) | |
| try: | |
| return textInfo._getPointFromOffset(prevOffset) | |
| except (NotImplementedError, LookupError, AttributeError) as e: | |
| log.debug(...) | |
| raise e |
There was a problem hiding this comment.
I kept both fallbacks for better precision and added debug logging to each. The final raise re-raises the original pointAtStart error, which is the most useful for debugging.
…fix/NVDAPythonConsole
Link to issue number:
fixes #19746
Summary of the issue:
Text caret follow would fail in some text editor (python console of nvda or notepad), if it would be the last character
Description of user facing changes:
text caret will now focus properly end character
Description of developer facing changes:
Description of development approach:
Update
_get_pointAtStartnow falls back to the previous character's position when the caret is at end-of-text and both_getBoundingRectFromOffsetand_getPointFromOffsetfail for the current offset.Testing strategy:
Manual
Known issues with pull request:
Code Review Checklist: