Closed devleejb closed 2 weeks ago
The changes made in the pull request involve modifications to the YorkieSyncPluginValue
class in the frontend/src/utils/yorkie/yorkieSync.ts
file. The updates enhance document synchronization with the CodeMirror editor by introducing a new variable to capture the current selection and updating the transaction specification for the view.dispatch
method. This allows for the restoration of the cursor position during document content updates while retaining the existing logic for handling remote changes.
File Path | Change Summary |
---|---|
frontend/src/utils/yorkie/yorkieSync.ts | Enhanced YorkieSyncPluginValue class to include selection handling in document synchronization with CodeMirror. Added logic to calculate and include cursor position in transaction specifications. |
sequenceDiagram
participant User
participant CodeMirror
participant Yorkie
User->>CodeMirror: Make changes to document
CodeMirror->>Yorkie: Dispatch changes with selection
Yorkie->>CodeMirror: Update document with new content
Yorkie->>CodeMirror: Send remote changes
CodeMirror->>User: Restore cursor position
In the land of code where rabbits play,
A sync was crafted, brightening the day.
With selections captured, oh what a sight,
The cursor dances, all feels just right!
Hopping through changes, we cheer and we sing,
For smoother edits, let the joy take wing! 🐇✨
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?
What this PR does / why we need it: This PR modifies the cursor movement logic triggered during a Snapshot Event. Previously, when a Snapshot Event occurred, the entire content was replaced, causing the cursor to jump to the top. This update ensures that the cursor remains in its intended position after the Snapshot Event.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: The previous implementation negatively impacted the user experience by causing disruption in text editing, as users would lose their cursor position unexpectedly. This change aims to improve usability by maintaining the cursor’s position during content updates.
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit