Skip to content

Fix regression: restore ability to move braille to next paragraph in LibreOffice Writer#19171

Closed
nvdaes wants to merge 10 commits intonvaccess:masterfrom
nvdaes:moveLibreOffice
Closed

Fix regression: restore ability to move braille to next paragraph in LibreOffice Writer#19171
nvdaes wants to merge 10 commits intonvaccess:masterfrom
nvdaes:moveLibreOffice

Conversation

@nvdaes
Copy link
Copy Markdown
Collaborator

@nvdaes nvdaes commented Nov 5, 2025

Link to issue number:

Fixes #19152

Summary of the issue:

Braille cannot be moved to next paragraph, due to a regression introduced in #18348

Description of user facing changes:

Braille can be moved to the next paragraph again.

Description of developer facing changes:

None.

Description of development approach:

Restore changes introduced for the move method in textInfos/offsets.py.
In nextLine of braille.py, if the cursor is not moved, expand to line before collapsing.
Revert "Fix off by one text length in EditTextInfo (#18767) (otherwise system test fail.

Testing strategy:

Tested locally with a Focus 40 braille display, in LibreOffice Writer and Notepad++:

  • Checked that, when scrolling forward with braille, the cursor is moved to the end of the document from the last line, also in LibreOffice Writer (this is a documented change since this was not happening in NVDA 2025.3.1).

  • Checked that the behavior is consistent regardless of the Read by paragraph option (when this is turned on or off).

  • Checked that the review cursor can be moved across lines, i.e., performing the review previous and review next line commands.

  • Tested proposal by @LeonarddeR mentioned in #issuecomment-3506121489
    The only difference found between Leonards's proposal and this pull request is that, with this PR, the cursor can be moved to the end of the documment in LibreOffice Writer from the last line, which is consistent with the behavior of other applications.

Known issues with pull request:

None.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@mltony
Copy link
Copy Markdown
Contributor

mltony commented Nov 5, 2025

You are essentially proposing to roll back my PR #18348.
This will most likely break #17430.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 5, 2025

@mltony

This will most likely break #17430.

You are right. I've updated the description of this PR reflecting this in known issues.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 5, 2025

Another possibility would be to revert completely #18348, but hope we find a better solution to fix this regression, keeping the proper behavior of Notepad++.

@mltony
Copy link
Copy Markdown
Contributor

mltony commented Nov 5, 2025

@nvdaes, I would strongly discourage reverting #18348 as it would reintroduce major regressions in textInfo API.
I think we should stop trying random solutions with hope that one of them will magically fix the issue. Someone needs to debug this issue with LibreOffice and understand why it happens. I offered my help but looks like there is no way to reproduce this without a Braille display.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 5, 2025

@mltony , hope we can find a solution without broken the API in an unappropriate way.
I think that either LibreOffice or Notepad++ may be investigated to the bug these issues. I think that the regression with LibreOffice should be fixed before the next stable version of NVDA.
I think that we should try to fix the Notepad++ issue, if possible, without reverting this PR.
Anyway, 2026.1 will include API breaking changes, so I'm open to revert this PR if needed.
cc: @gerald-hartig

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 6, 2025

With the last commit, braille can be scrolled forward in LibreOffice and in Notepad++.

@nvdaes nvdaes changed the title Fix regression: restore ability to move braille to next paragraph Fix regression: restore ability to move braille to next paragraph in LibreOffice Writer Nov 6, 2025
@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 7, 2025

@LeonarddeR , seems that, with this PR, we need to revert your a514710 commit, since in fact we are reverting code introduced in #18348.
Let's try to see if test pass reverting this commit, as I expect.

@LeonarddeR
Copy link
Copy Markdown
Collaborator

As well as @mltony, I strongly discourage going forward the current way. This is most likely a bug in the text info implementation used in libre office. The current pr touches unrelated code, such as in edit text info which is not used in Libre Office as far as I can recall.
I'm happy to look into this further, though not sure when I could.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 7, 2025

@LeonarddeR wrote:

The current pr touches unrelated code, such as in edit text info which is not used in Libre Office as far as I can recall.

No, this PR is reverting changes, and, in addition, touches code just in the braille nextLine function.

If textInfo issues can be fixed for buggy programs, like LibreOffice or Notepad++ (in case they contain bugs), I agree.

I'll wait for feedback from @SaschaCowley , @seanbudd or @gerald-hartig , to see if I should go forward with this fixing remaining failures in tests.

@LeonarddeR
Copy link
Copy Markdown
Collaborator

LeonarddeR commented Nov 8, 2025

I just tested the oneliner in #19152 (comment) with braille. It turns out that with this change, it is still possible to route to the last character of a document. Therefore I think it is safe enough to apply it.
If you want an even safer approach, you can patch TreeCompoundTextInfo._getTextInfos to set allowMoveToOffsetPastEnd for every text info before yielding it, except for the last one. e.g.

	def _getTextInfos(self):
		start = self._start.copy()
		start.allowMoveToOffsetPastEnd = startIsEnd = self._startObj == self._endObj
		yield start
		if startIsEnd:
			return
		obj = self._startObj.flowsTo
		while obj and obj != self._endObj:
			info = obj.makeTextInfo(textInfos.POSITION_ALL)
			info.allowMoveToOffsetPastEnd = False
			yield info
			obj = obj.flowsTo
		yield self._end.copy()

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 8, 2025

@LeonarddeR wrote:

with this change, it is still possible to route to the last character of a document.

I noted that in LibreOffice Writer documents, with NVDA 2025.3.1rc1, if the last line is not empty, the corsor couldn't be moved with braille to the last position, but it can be moved there with this change in braille.py. I'll test your proposed changes about textInfo and, if it works as expected, I'll apply them.
Thanks a lot for your great feedback.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 8, 2025

@LeonarddeR , as mentioned in #19152 , for now I'll leave this PR changing the nextLine function in braille.py. I may fix tests and request a review from NV Access, since this allows to move the cursor to the last position of a document in LibreOffice writer, and this is consistent with other applications. I created a different pull request closed by @seanbudd according with @gerald-hartig comment, where he mentioned that they prefer to revert changes in textInfos/offsets.py.

I'll do all this now, and if further work is needed, I may continue or even test changes if you create a different PR.

@nvdaes nvdaes marked this pull request as ready for review November 8, 2025 13:57
@nvdaes nvdaes requested a review from a team as a code owner November 8, 2025 13:57
@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 8, 2025

Please reviewers, take special care about #18767. I reverted changes, but I'm not sure if something else needs to be done. I have tested with Notepad on Windows 11 64 bits, and the story lenght seems to be right.

Copy link
Copy Markdown
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

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

@LeonarddeR
Copy link
Copy Markdown
Collaborator

LeonarddeR commented Nov 8, 2025

I created a different pull request closed by @seanbudd according with @gerald-hartig comment, where he mentioned that they prefer to revert changes in textInfos/offsets.py.

I can understand why the request would be to revert the changes if they really introduce a bug that can't be solved otherwise. However, the solution I proposed in #19171 (comment) avoids such a revert. If anyone insists on reverting which I'd regret and advise against, there is a revert template that should be used.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 8, 2025

@LeonarddeR wrote:

If anyone insists on reverting which I'd regret and advise against, there is a revert template that should be used.

But this is not reverting #18348 completely, since a docstring is maintained
And a commit made by you has been reverted to fix tests after reverting functionality (not the complete PR) created by @mltony #18348.

This is marked as ready for review. If NV Access prefers your proposal, I advice them to close this PR and you can create a new one.

This reverts commit dd78ae4.
# Py3 review: investigation with Python 2 NVDA revealed that
# adding 1 to this creates an off by one error.
# Tested using Wordpad, enforcing EditTextInfo as the textInfo implementation.
return textLen + 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nvdaes, this change is dangerous as it might affect other textInfos. I wouldn't touch this file - especially since you're trying to fix LibreOffice problem.

# Py3 review: investigation with Python 2 NVDA revealed that
# adding 1 to this created an off by one error.
# Tested using Notepad
return watchdog.cancellableSendMessage(self.obj.windowHandle, winUser.WM_GETTEXTLENGTH, 0, 0) + 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here - this might break other textInfo API clients throughout NVDA code.

shouldCollapseToEnd = True
# This will allow to move to next paragraph In LibreOffice _Writer,
# And consistently move to the last position in different applications.
dest.expand(textInfos.UNIT_LINE)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we use self._getReadingUnit() instead of UNIT_LINE?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we should expand to line, as done in Commit 70cd311, but touching the nextLine function of braille.py, to get more consistent results between applications, even if textIfno bugs inherent to these apps should be fixed, additionally.

lowLimit = 0
highLimit = self._getStoryLength()
if self.allowMoveToOffsetPastEnd:
if self.allowMoveToOffsetPastEnd and unit == textInfos.UNIT_CHARACTER:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This effectively rolls back #18348.
I don't think this is justified. It seems to me that you are replacing #18348 with a hack. It somehow works but we don't have a clear understanding how exactly. This hacky approach will inevitably backfire in other parts and generate more bugs that need to be fixed later down the road.
I think @LeonarddeR investigated this issue and proposed a much cleaner solution to fix this bug. I would strongly suggest to focus on that cleaner solution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've tested @LeonarddeR proposal, and I prefer, at least for now, the solution proposed by me in this PR. Seems that touching TreeCompoundTextInfo._getTextInfos , and setting allowMoveToOffsetPastEnd to False in the SymphonyTextInfo class of the soffice.py module, when we reach the last line of a Writer document, if this line is not empty, the cursor is not moved to the end of the line, and this is not consistent with other applications.
Both approaches fix the regression, but I don't think that I'm aplying a hack. I'm touching the function to move to next line in the braille module. This regression is related to braille. So I'm not against fixing bugs in textInfos.
Anyway, I won't close this. This is ready for review, and if the maintainers of the project think that this should be closed, and they provide reasoning about possible issues with my approach, I'll be happy if they close this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At this point our best understanding is that OffsetTextInfo.allowMoveToOffsetPastEnd should apply to any type of moving, regardless of whether we're moving by character or by line. It is hard for me to imagine a textInfo where a certain position can only be moved to by character, but not by line or paragraph.
Your change in textInfos\offsets.py:666 reverts my PR #18348. You are restoring behavior that is clearly wrong. That's why that's a hack.

@mltony
Copy link
Copy Markdown
Contributor

mltony commented Nov 10, 2025

CC: @Emil-18 - TLDR: @nvdaes is proposing to roll back my textInfos fix and introduce some hacky logic to fix another braille bug. Would be great to hear your opinion.

@LeonarddeR
Copy link
Copy Markdown
Collaborator

Let's stop criticizing each other’s solutions. It only wastes time and leads to heated discussions. Perhaps NV Access can give a final say on which path to take?

@Emil-18
Copy link
Copy Markdown
Contributor

Emil-18 commented Nov 10, 2025

@nvdaes I am with @mltony on this one. This isn't a braille issue, but an issue with the SymphonyDocumentTextInfo, as the same issue occurs when moving the review cursor to the next line. Your Approach would almost be the same as rewriting the speakObject function to speak the name fetched directly from an accessibillity API (or other source) if some condition is met, instead of exposing the name through an NVDAObject and allowing the speakObject function to fetch the name from the object.
I don't have a braille display to test this at the moment, but wouldn't this approach brake the "read by paragraph" option?

To be honest, I would rather have the issue, and wait until it is fixed in the text info, than fixing it just for braille users, and create inconsistent behavior between speech and braille

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 10, 2025

@Emil-18 wrote:

I don't have a braille display to test this at the moment, but wouldn't this approach brake the "read by paragraph" option?

No.

I'll update the description of this PR to mention that this doesn't break it, and that the only difference with Leonard proposal that I find is that this PR makes the cursor to be moved at the end of the document when the las line is reached scrolling with braille, on consistency with behavior of other applications. With this PR the review cursor can be also moved across lines.

@Emil-18
Copy link
Copy Markdown
Contributor

Emil-18 commented Nov 10, 2025

@nvdaes I tested it, and it reintroduces the issue with not being able to move to the last line in notepad ++ if the last line is empty

@LeonarddeR
Copy link
Copy Markdown
Collaborator

I'm going to close this pr for now, due to the following reasons:

  1. Several concerns have been raised by a majority of participants to the pr, including @mltony, @Emil-18 and myself.
  2. As pointed out by @Emil-18 in Fix regression: restore ability to move braille to next paragraph in LibreOffice Writer #19171 (comment), the current state of the pr reintroduces another issue.
  3. I put some research into compound documents code. That code needs proper unit testing against working code (e.g. 2025.3.1) state before I think it is safe to continue with a proposal that fixes the issue. In other words, we need to get back to the drawing board. LibreOffice Writer: Cannot move braille to next paragraph #19152 is the right place for this.

Closing this pull request also creates responsibilities. I hereby promise that I will submit a new pull request that at least has the necessary unit tests to validate the behavior of compound documents, so that we can then strive for a fix with a minimal footprint.

@LeonarddeR LeonarddeR closed this Nov 10, 2025
@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 10, 2025

@LeonarddeR wrote:

the current state of the pr reintroduces another issue.

Not here. In Notepad++ on my system, on Windows 11 64 bits, there`s not difference between the behavior of braille in NVDA 2025.3.1 and this PR. Perhaps steps to reproduce the issue should be provided.

@LeonarddeR wrote:

Several concerns have been raised by a majority of participants to the pr,

Just 4 participants. I think we should give more time to NV Access people, considering that they suggested to revert changes made in #18348 .

I'm happy if you want to investigate better solutions, but I don't think that you should close this without giving time to NV Access to provide feedback, and time to me in case something needs to be done from my part.
I would never do this with a PR created by you.
Anyway, I won't reopen it, and I suggest you to let things like that. I don't want to create a war with this.
Anyway, @gerald-hartig and @seanbudd , since I created this in response to your previous request to revert changes, please let me know if I should continue with this work or not.

@Emil-18
Copy link
Copy Markdown
Contributor

Emil-18 commented Nov 10, 2025

@nvdaes The issue in notepad ++ in your pr isn't with braille, but with the OffsetsTextInfo. It works when moving to next line with braille, because you expand the TextInfo to line

Steps to reproduce

  • Open Notepad ++
  • Type something and press enter
  • Move the cursor to the first line
  • Press numb pad 9 to move the review cursor to the next line

Actual behavior

NVDA says "bottom" and the review cursor doesn't move

Expeccted behavior

The review cursor moves to the blank line

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 10, 2025

@LeonarddeR wrote:

the current state of the pr reintroduces another issue.

Not here. In Notepad++ on my system, on Windows 11 64 bits, there`s not difference between the behavior of braille in NVDA 2025.3.1 and this PR. Perhaps steps to reproduce the issue should be provided.

@LeonarddeR wrote:

Several concerns have been raised by a majority of participants to the pr,

Just 4 participants. I think we should give more time to NV Access people, considering that they suggested to revert changes made in #18348 .

I'm happy if you want to investigate better solutions, but I don't think that you should close this without giving time to NV Access to provide feedback, and time to me in case something needs to be done from my part.
I would never do this with a PR created by you.
Anyway, I won't reopen it, and I suggest you to let things like that. I don't want to create a war with this.
Anyway, @gerald-hartig and @seanbudd , since I created this in response to your previous request to revert changes, please let me know if I should continue with this work or not.

@Emil-18 , in fact the described issue with Notepad++ was fixed in master, where the p2 regression with LibreOffice was introduced.
I agree about investigating better solutions, but you have reported this issue just a few hours ago, we are just 4 participants, the maintainers of the NVDA project, who commented in #19152 issue, haven't participated here, probably due to time, and this has been closed. No, this is not good to provide a constructive environment, and I won't participate here unless the maintainers of this project say something, since a work started due to a conversation with them has been interrupted.
Anyway this is not the end of the world. I don't want to produce a flame or a tragedy for this, but I prefer not to discuss here unless maintainers say something.

@LeonarddeR
Copy link
Copy Markdown
Collaborator

@nvdaes I might have been too quick here, I'm just seeing to much difficulties to continue with this. I've done several work on this today and I can just say with certainty that the work you are doing on this issue, though greatly appreciated, does not do justice to the underlying problem.

I'm happy to reopen this as long as you leave this a draft until NV Access kicks in with further triage.

@seanbudd
Copy link
Copy Markdown
Member

Hi all - per our release process, unless a clean full fix is immediately available, we are for reverting PRs that decrease the overall quality of NVDA.
This is so we can keep our releases unblocked and get the highest quality code released.

Further work to properly fix this issue and reintroduce changes from #18348 is welcome.

@nvdaes - please use the revert PR template and minimize these changes to the partial revert required to restore behaviour before #18348. Any other fixes should be in a separate PR, i.e. what @LeonarddeR is proposing to fix the issue fully.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Nov 11, 2025
@mltony
Copy link
Copy Markdown
Contributor

mltony commented Nov 11, 2025

@seanbudd, fully reverting #18348 will reintroduce the ugly hack from #17431. Basically the whole textInfo API would be broken. And this will break many add-ons. Could you make sure that ugly hack doesn't get reintroduced?

@SaschaCowley
Copy link
Copy Markdown
Member

@mltony that is exactly why we have asked for a partial revert.

@nvdaes
Copy link
Copy Markdown
Collaborator Author

nvdaes commented Nov 11, 2025

Please see #19203

@seanbudd
Copy link
Copy Markdown
Member

Closing in favour of #19204 and #19203

@seanbudd seanbudd closed this Nov 12, 2025
seanbudd pushed a commit that referenced this pull request Nov 17, 2025
Fixes #19152
Fixup for #18348,
Supersedes #19203, #19171
Summary of the issue:

In LibreOffice, it is not possible to use braille panning since #18348.
Description of user facing changes:

Panning works again in LibreOffice
Description of developer facing changes:

removed OffsetsTextInfo.allowMoveToOffsetPastEnd.
Description of development approach:

Rather than having one allowMoveToOffsetPastEnd class attribute, introduce a allowMoveToUnitOffsetPastEnd method that takes a unit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LibreOffice Writer: Cannot move braille to next paragraph

6 participants