From 7227d514ba2ac791debe25bea64e17c92bbeecaf Mon Sep 17 00:00:00 2001 From: James Teh Date: Mon, 29 Jul 2024 10:52:43 +1000 Subject: [PATCH] MozillaCompoundTextInfo: Don't adjust for the end of a line at the end of an object. (#16914) Fixup of #16745. Summary of the issue: In my work on #16745, I apparently neglected to consider the end of an inline object such as a link. In that case, adjusting for the line end caused NVDA to report blank when moving to the character after the link instead of reporting the actual character. Description of user facing changes When editing text in Firefox, NVDA now reports the correct character instead of blank when pressing right arrow to move out of a link. This doesn't need a change log entry if we can get this into beta because the bug will not have shipped in release. Description of development approach Return False in _isCaretAtEndOfLine if we're at the end of an object. While the end of an object could indeed be the end of a line, we don't need the special adjustment in this case and the adjustment causes problems if it isn't the end of a line. This also means we can remove the change in #16763 because that was only ever a problem for a line feed at the end of an object anyway. This new fix covers both cases --- source/NVDAObjects/IAccessible/ia2TextMozilla.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/IAccessible/ia2TextMozilla.py b/source/NVDAObjects/IAccessible/ia2TextMozilla.py index 96c83da63ae..10dbedc742d 100644 --- a/source/NVDAObjects/IAccessible/ia2TextMozilla.py +++ b/source/NVDAObjects/IAccessible/ia2TextMozilla.py @@ -106,10 +106,12 @@ def _isCaretAtEndOfLine(self, caretObj: IAccessible) -> bool: # means this is not the insertion point at the end of a line. if start != end: return False - # If there is a line feed before us, this is an empty line. We don't want - # to do any special adjustment in this case. Otherwise, we will report the - # previous line instead of the empty one. - if start > 0 and caretObj.IAccessibleTextObject.text(start - 1, start) == "\n": + # If this is the end of the object, it might be the end of a line, but it + # might just be the end of the object on a line containing multiple objects. + # It's also possible that this is an empty last line, in which case any + # adjustment would cause us to report the previous line instead of the empty + # one. Either way, we don't need the special end of line adjustment. + if start > 0 and start == caretObj.IAccessibleTextObject.nCharacters: return False return True except COMError: