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

Desktop: Rich Text Editor: Preserve cursor location when updating editor content #10781

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Jul 25, 2024

Summary

This pull request preserves the Rich Text Editor's cursor location when the note content is updated externally.

This may partially fix #8960 (only the Rich Text Editor case).

This should:

  • Preserve the cursor location and scroll position when a note open in the Rich Text Editor is changed by an external editor. This is useful when switching back and forth between the Rich Text Editor and an external editor with keyboard shortcuts (e.g. alt-tab).
  • Prevent the cursor from jumping to the top of the note when changed by a sync.
    • Note: This has only been tested with a manual sync.

Testing plan

This pull request has been manually tested by:

  1. Ensure that the Rich Text Editor is open.
  2. Create a new note.
  3. Open the note in an external editor (gnome-text-editor).
  4. Using the external editor, set the note content to a long file with KaTeX blocks, headings, and paragraphs (I used this content: file.md).
  5. In the Rich Text Editor, move the cursor to the last heading.
  6. Delete the first math block from the external editor and save.
  7. Verify that the cursor doesn't move more than a single line.
    • For me, the cursor moved down a single line.
  8. In the external editor, undo and save again.
  9. Verify that the Rich Text Editor cursor has moved back to the heading.
  10. Switch to a different note.
  11. Verify that the cursor has moved to the top of the note.
  12. Switch back to the original note and move the cursor to the second-to-last heading.
  13. Set up file system sync.
  14. Sync another client.
  15. On the just-synced client,
    • Delete one of the math blocks above the second-to-last heading.
    • Sync.
  16. Sync the original client.
  17. Verify that the cursor moves less than 1-2 lines.
    • For me, the cursor moves to the line just below the originally-selected heading.

This has been tested successfully on Ubuntu 24.04.

…e the cursor location when updating editor content
@laurent22 laurent22 merged commit 40bd2df into laurent22:dev Jul 28, 2024
10 checks passed
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.

Cursor jumps to top of editor when typing
2 participants