Skip to content

Commit

Permalink
Cleanup and apply fix to next word script as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofdusk committed Oct 19, 2021
1 parent 5bbf2e9 commit ec1e156
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,15 +1324,15 @@ def script_review_currentLine(self,gesture):
category=SCRCAT_TEXTREVIEW,
gestures=("kb:numpad9", "kb(laptop):NVDA+downArrow", "ts(text):flickDown")
)
def script_review_nextLine(self,gesture):
def script_review_nextLine(self, gesture):
origInfo = api.getReviewPosition().copy()
origInfo.collapse()
info = origInfo.copy()
res=info.move(textInfos.UNIT_LINE,1)
res = info.move(textInfos.UNIT_LINE, 1)
newLine = info.copy()
newLine.expand(textInfos.UNIT_LINE)
# Some implementations of move by line 1 may succed one more time than expected,
# Landing on the exclosive end of the document.
# #12808: Some implementations of move forward by one line may succeed one more time than expected,
# Landing on the exclusive end of the document.
# Therefore, verify that expanding after the move does result in being on a new line,
# I.e. the new line starts after the original review cursor position.
if res == 0 or newLine.start <= origInfo.start:
Expand Down Expand Up @@ -1400,18 +1400,23 @@ def script_review_currentWord(self,gesture):
category=SCRCAT_TEXTREVIEW,
gestures=("kb:numpad6", "kb(laptop):NVDA+control+rightArrow", "ts(text):2finger_flickRight")
)
def script_review_nextWord(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_WORD)
info.collapse()
res=info.move(textInfos.UNIT_WORD,1)
if res==0:
def script_review_nextWord(self, gesture):
origInfo = api.getReviewPosition().copy()
origInfo.collapse()
info = origInfo.copy()
res = info.move(textInfos.UNIT_WORD, 1)
newWord = info.copy()
newWord.expand(textInfos.UNIT_WORD)
# #12808: Some implementations of move forward by one word may succeed one more time than expected,
# Landing on the exclusive end of the document.
# Therefore, verify that expanding after the move does result in being on a new word,
# I.e. the new word starts after the original review cursor position.
if res == 0 or newWord.start <= origInfo.start:
# Translators: a message reported when review cursor is at the bottom line of the current navigator object.
ui.reviewMessage(_("Bottom"))
else:
api.setReviewPosition(info)
info.expand(textInfos.UNIT_WORD)
speech.speakTextInfo(info, reason=controlTypes.OutputReason.CARET, unit=textInfos.UNIT_WORD)
speech.speakTextInfo(newWord, unit=textInfos.UNIT_WORD, reason=controlTypes.OutputReason.CARET)

@script(
description=_(
Expand Down

0 comments on commit ec1e156

Please sign in to comment.