Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MozillaCompoundTextInfo: Don't adjust for the end of a line if the previous character is a line feed. #16763

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

jcsteh
Copy link
Contributor

@jcsteh jcsteh commented Jun 27, 2024

Link to issue number:

Fixup of #16745.

Summary of the issue:

In my work on #16745, I neglected to consider an empty line after a line feed. In that case, adjusting for the line end caused NVDA to read from the previous line instead of the empty one.

Description of user facing changes

In Firefox, NVDA no longer speaks the previous line when the caret is on the last line and the last line is empty. However, this does not need a change log entry because this bug never shipped in release.

Description of development approach

Don't set the _isInsertionPointAtEndOfLine flag to True if the previous character is a line feed. This prevents the line end adjustment.

Because this additional check makes the code a little more complex, I refactored this code into a helper method.

Testing strategy:

Test case:
data:text/html,<textarea>ab%0a</textarea>

  1. Focus the textarea.
  2. Press control+end.
    • Incorrect result (before this PR): "ab"
    • Correct result (after this PR): "blank"

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.

Summary by CodeRabbit

  • New Features
    • Improved caret position detection to handle cases where the caret is at the end of a line.

@jcsteh jcsteh requested a review from a team as a code owner June 27, 2024 12:57
@jcsteh jcsteh requested a review from seanbudd June 27, 2024 12:57
Copy link
Contributor

coderabbitai bot commented Jun 27, 2024

Walkthrough

The ia2TextMozilla.py file has been enhanced by adding a method _isCaretAtEndOfLine, which checks if the caret is at the end of a line. The method's introduction aims to improve caret position handling, especially when it is at line ends. Additionally, the __init__ method now utilizes _isCaretAtEndOfLine to set the _isEndOfLineInsertionPoint attribute, refining the caret tracking logic.

Changes

Files Change Summary
.../ia2TextMozilla.py Added the _isCaretAtEndOfLine method and updated the __init__ method to use it for setting _isEndOfLineInsertionPoint.

Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 23cb96b and c0aacb9.

Files selected for processing (1)
  • source/NVDAObjects/IAccessible/ia2TextMozilla.py (2 hunks)
Additional context used
Path-based instructions (1)
source/NVDAObjects/IAccessible/ia2TextMozilla.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious.


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

Additional comments not posted (1)
source/NVDAObjects/IAccessible/ia2TextMozilla.py (1)

85-109: Review of _isCaretAtEndOfLine Method Implementation

The method _isCaretAtEndOfLine is designed to determine whether the caret is at the end of a line. The implementation uses IA2_TEXT_OFFSET_CARET and IA2_TEXT_BOUNDARY_CHAR to fetch the character at the caret's position and checks if it's a line feed. The logic appears robust and correctly handles the case where the caret is followed by a line feed, indicating an empty line.

  • Correctness: The method correctly checks for the presence of a line feed character to determine if the line is empty.
  • Error Handling: Adequate error handling is present with a try-except block catching COMError, which might occur if there's an issue accessing the caret's position or text.
  • Logging: Debug logging is used effectively to log issues when determining the caret's position.
  • Performance: The method is efficient in terms of performance as it directly accesses the required text position and performs minimal operations.

Overall, the method is well-implemented and should function as expected based on the description in the PR.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

@seanbudd seanbudd merged commit 04e55d5 into nvaccess:master Jun 28, 2024
1 check passed
@jcsteh jcsteh deleted the firefoxEol2 branch June 29, 2024 02:01
seanbudd pushed a commit that referenced this pull request Jul 29, 2024
…d 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
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.

2 participants