nvaccess / nvda

NVDA, the free and open source Screen Reader for Microsoft Windows
https://www.nvaccess.org/
Other
2.12k stars 638 forks source link

Add commands to move the review cursor to the first and last character of selected text #17393

Closed nvdaes closed 4 days ago

nvdaes commented 2 weeks ago

Link to issue number:

Fixes #17299

Summary of the issue:

NVDA doesn't have commands to move the review cursor to start and end of selection, which may be useful to review the selected text.

Description of user facing changes

NVDA+alt+home and NVDA+alt+end can be used to move the review cursor to the first and last carácter of selected text.

Description of development approach

In globalCommands.py, GlobalCommands class, a staticmethod has been added to get the current selection. This is used to scripts added to move the review cursor to start and end of selection, similar to other scripts used to move the review cursor.

Testing strategy:

Tested manually in a webpage and in Notepad.

Known issues with pull request:

None.

Code Review Checklist:

@coderabbitai summary

burmancomp commented 1 week ago

Thank you! It works most of time but could you investigate situation in ms word when uia is used only when necessary. In windows 11 23h2 and word 2019 I got runtime error.

You could try with text like:

"line 1 line 2 line 3 line 4"

Note that no new line after number 4. Then try to select lines line 3 and line 4 so that you are in the start of line 3, and then press twice shift+down arrow. Then use nvda+alt+home, and try nvda+alt+end. I got following:

Input: kb(laptop):NVDA+alt+end ERROR - scriptHandler.executeScript (13:36:45.912) - MainThread (6848): error executing script: <bound method GlobalCommands.script_review_endOfSelection of <globalCommands.GlobalCommands object at 0x0A4AFA10>> with gesture 'NVDA+alt+end' Traceback (most recent call last): File "scriptHandler.pyc", line 300, in executeScript File "globalCommands.pyc", line 2251, in script_review_endOfSelection File "NVDAObjects\window\winword.pyc", line 1226, in collapse RuntimeError

nvdaes commented 1 week ago

@burmancomp , please, feel free to test again in MS Word with UIA enabled only when needed or with other configurations and applications. I think that now this is fixed, according to my tests. Now we move the end of the selection info one character back before collapsing, instead of collapsing and then moving back one character.

burmancomp commented 1 week ago

Works for me, thank you!

nvdaes commented 1 week ago

Then let's mark this as ready for review.

nvdaes commented 6 days ago

@SaschaCowley , think that all your suggestions are addressed now. Thanks for your review, and thanks all reviewers.