Fix TextInfo.collapse() in Notepad++#18338
Conversation
|
Tony wrote:
No, I didn't claim this. I said:
I've reviewed the source code and likes good to me. I haven't tested it yet. I think that your issue isn't triaged, may require a product decission by NV Access, since breaking changes were accepted, so I'll wait to test it. |
See test results for failed build of commit 9d1cf1176e |
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
|
@nvdaes, please test this at your earliest convenience. I don't think this requires a project decision as this is clearly a bug to be fixed - but @seanbudd and @SaschaCowley are to correct me if I'm wrong. |
|
I'm a bit worried about these changes as well as the changes in #17431. In my modest opinion, they obfuscate an underlying bug, namely that |
|
I've tested this and works as expected. Thanks @mltony |
|
I think we must also check for the case where word wrap is enabled. I always disable that in np++. |
|
@LeonarddeR, I agree fixing the underlying bug would be a better path. Can you explain in more details - like steps to repro - what is broken with
What is it supposed to return for an empty line? |
You can compare the behavior of NotePad++ and a document in classic notepad, for example. Compare the output of
For an empty line, since an empty line contains
|
Let me see if I can repro this without Braille display at hand. |
|
Ok, I think I found the root cause: in Notepad++ when you try to do |
|
I think I found the root cause why |
Fixes #18320. This is my second attempt to fix it without breaking #17430. For the reference, the first attempt was #18338, which is abandoned, and which didn't fix the root cause, but just decoupled @nvdaes's commit from TextInfo API. This PR however fixes the root cause of #17430. Summary of the issue: Commit 70cd311 by @nvdaes introduced a bug in TextInfo API: `TextInfo.collapse()` now unnecessarily jumps to the next paragraph in Notepad++. This bug also made its way into 2025.1 release. I investigated the braille issue #17430 further and it boiled down to an issue with `OffsetTextInfo.move()` implementation: it turns out that unless it moves by character, it is unable to move to the very last position in the document. Fixing `OffsetTextInfo.move()` implementation. Description of user facing changes: None Description of developer facing changes: `OffsetTextInfo.collapse()` now works correctly in Notepad++. `OffsetTextInfo.move()` can now move to the very last position even when unit is set to line or paragraph. Description of development approach: 1. In `OffsetTextInfo.move()` modified the condition when `self.allowMoveToOffsetPastEnd` to increase `highLimit` regardless of current unit - previously this would only allow when unit is character. 2. Removed `ScintillaTextInfo.expand()` override. Testing strategy: 1. Tested with use case provided in #18320. 2. Tested that `OffsetTextInfo.move('line', 1)` can now successfully go to the very last line in Notepad++ even if the last line is empty. This should be the proper fix for #17430. Known issues with pull request: None
Link to issue number:
Fixes #18320.
Summary of the issue:
Commit 70cd311 by @nvdaes introduced a bug in TextInfo API:
TextInfo.collapse()now unnecessarily jumps to the next paragraph in Notepad++. This bug also made its way into 2025.1 release. There are several problems with this:collapseis frequently used method.collapse()doesn't reflect that the TextInfo would also jump.@nvdaes tried to fix #17430 with this commit.
I propose this PR as a way to fix TextInfo API without breaking #17430.
Description of user facing changes:
N/A
Description of developer facing changes:
TextInfo.collapse()now works correctly in Notepad++.Description of development approach:
Created a new method
TextInfo.collapseAndMaybeMoveToNextParagraphso that the logic implemented by @nvdaes can stay in place, but not affect other users of TextInfo API.TBH I would rather not pollute TextInfo API, but I don't have visibility into braille subsystem - and I don't have a Braille display to test any changes - and @nvdaes claims there is no other way to fix #17430. So This PR is a compromise: I kept @nvdaes's logic in place at the cost of introducing a new unnecessary method in TextInfo API. I think a cleaner way would be for @nvdaes to dfix the issue in
def nextLineanddef previousLinein braille.py., but @nvdaes claims that's impossible (see the discussion in #18320).Testing strategy:
Tested with use case provided in #18320.
@nvdaes, can you test that this PR doesn't break #17430? I don't have a Braille display to test it on my end.
Known issues with pull request:
N/A
Code Review Checklist:
@coderabbitai summary