Skip to content

Ignore RuntimeError when moving in word.#7133

Merged
feerrenrut merged 2 commits into
masterfrom
i7009-winWordRuntimeError
May 30, 2017
Merged

Ignore RuntimeError when moving in word.#7133
feerrenrut merged 2 commits into
masterfrom
i7009-winWordRuntimeError

Conversation

@feerrenrut

@feerrenrut feerrenrut commented May 3, 2017

Copy link
Copy Markdown
Contributor

Fix for #7009

When opening a blank word document there seems to be a "virtual line-feed" character. The caret can not be moved past this character (I.E. you can not insert after it). It can be selected and copied, but not deleted. It acts as an exclusive end in textInfo end offset. The exception is thrown when the new end offset is less than the old end offset. When calling collapse (with end=true) on an object that has its end offset set to this "virtual line-feed" character, the endOffset is reduced by one, since start can not be this final character (since its exclusive).

The exception seen in #7009 is used to control the program flow for say-all. Several other options for fixing this have been considered:

Returning an error code:

This would require that all implementations of collapse return appropriate values.

Move the check to the say-all code.

Since say-all seems to be the only thing depending on this functionality (to stop an infinite loop), we could move this check to there. To do this we would be relying on textInfo.copy() to cache the pre collapse value, and then textInfo.compareEndpoints() to see if the endOffset was now less. Since there is some concern that compareEndpoints() does not behave consistently in all implementations this option is considered too risky.

Ignore this exception when moving the caret

This PR proposes handling this (by ignoring the exception) in the _caretMovementScriptHelper function in cursorManager.py.

@feerrenrut feerrenrut requested a review from michaelDCurran May 3, 2017 06:31
Comment thread source/cursorManager.py Outdated
try:
info.collapse(end=posUnitEnd)
except RuntimeError:
# MS Word has a "virtual linefeed" at the end of the document which can cause RuntimError to be raised.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtimError -> RuntimeError

@feerrenrut

Copy link
Copy Markdown
Contributor Author

Incubated in commit 90941f4656 but the comment refered to the wrong PR. I will apply the labels manually.

@feerrenrut feerrenrut self-assigned this May 3, 2017
@feerrenrut feerrenrut merged commit 1c068b7 into master May 30, 2017
@nvaccessAuto nvaccessAuto added this to the 2017.3 milestone May 30, 2017
@feerrenrut feerrenrut deleted the i7009-winWordRuntimeError branch May 30, 2017 09:50
feerrenrut added a commit that referenced this pull request May 30, 2017
- PR #7169 : Editable div elements in Chrome are no longer have their label reported as their value while in browse mode. (Issue #7153)
- PR #6396 : An unbound gesture (script_restart) has been added to allow NVDA to be restarted quickly. (PR #6396)
- PR #6777 : A Braille setting has been added to "show messages indefinitely". (Issue #6669)
- PR #7133 : Pressing end while in browse mode of an empty Microsoft Word document no longer causes a runtime error. (Issue #7009)
- PR #6868 : The keyboard layout can now be set from the NVDA Welcome dialog. (Issue #6863)
- PR #6813 : The names of "landmarks" are abbreviated in Braille (Issue #3975)
@derekriemer

Copy link
Copy Markdown
Collaborator

Should we close #7009 now?

@feerrenrut

Copy link
Copy Markdown
Contributor Author

Opps, I wrote "Fix for..." instead of "Fixes..." I'll close it now.

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.

4 participants