Fix off by one text length in EditTextInfo#18767
Merged
Merged
Conversation
79d950f to
d0babfe
Compare
Collaborator
Author
|
I think that the failing test might actually be a good thing. Will look into this. |
Collaborator
Author
|
It was indeed a bug in the system test, or rather, the system test compensated for the off by one bug. Review cursor behavior in Notepad is now in line with notepad++, Word, Firefox, etc. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an off-by-one error in the EditTextInfo class that was causing incorrect text length calculations, particularly affecting caret position reporting in classic Notepad and other Win32 edit controls.
- Removes erroneous
+ 1operations in_getStoryLength()method that were causing text length to be reported as one character longer than actual - Updates protected text masking to use correct length calculation
- Adjusts system tests to expect correct character reporting instead of erroneous "blank" characters
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| user_docs/en/changes.md | Adds changelog entry documenting the text position accuracy fix |
| source/NVDAObjects/window/edit.py | Removes off-by-one errors in story length calculation and protected text handling |
| source/textInfos/offsets.py | Removes unnecessary length constraint in uniscribe offset calculation |
| tests/system/robot/symbolPronunciationTests.py | Updates test expectations to match corrected behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
seanbudd
approved these changes
Aug 31, 2025
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
nvdaes
added a commit
to nvdaes/nvda
that referenced
this pull request
Nov 7, 2025
This reverts commit a514710.
This was referenced Nov 8, 2025
Closed
nvdaes
added a commit
to nvdaes/nvda
that referenced
this pull request
Nov 15, 2025
This reverts commit a514710.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Related to #18744
Follow up of #18348
Summary of the issue:
When working on #18744, I again stumbled upon the fact that the story length reported by EditTextInfo is too high. This was discovered after system test failures caused by #18348, i.e. reporting of an extraneous blank at the end of the document when using NVDA review cursor. Note, this is not a bug in #18348 and was accounted for in #18744 after the test failure.
To reproduce
aObserve that NVDA reports 50%, not 100%
Observe that
nav.makeTextInfo("caret")._getStoryLength()reports 2, not 1Description of user facing changes:
None
Description of developer facing changes:
None
Description of development approach:
Fixed the off by one errors by removing the
+ 1cases.Testing strategy:
Tested str from this pr.
Known issues with pull request:
None
Code Review Checklist:
@coderabbitai summary