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

Issues with cursor positioning and scroll behavior during Snapshot Events in CodeMirror #402

Open
devleejb opened this issue Nov 4, 2024 · 1 comment
Labels
bug 🐞 Something isn't working

Comments

@devleejb
Copy link
Member

devleejb commented Nov 4, 2024

What happened:
When a Snapshot Event occurs in CodeMirror, it overwrites the content within the editor with Snapshot data and moves the cursor based on Presence. However, several issues are observed:

2024-11-03.1.56.04.mov
  1. While dragging with the mouse, if a Snapshot Event occurs, the starting point of the drag moves to the topmost position.
  2. If a Snapshot Event occurs during text input, there are intermittent instances where the scroll jumps to the top and then returns to the current position.

It seems that this issue is related to the moment the code is executed, because when dragging is done via keyboard, the problem does not occur. The following code snippet appears to be the culprit:

view.dispatch({
    changes: { from: 0, to: view.state.doc.length, insert: text.toString() },
    annotations: [Transaction.remote.of(true)],
    selection: {
        anchor: ...,
        head: ...,
    }
});

What you expected to happen:
The cursor should remain at the correct position during and after the Snapshot Event, without any scroll jumps or unexpected behavior.

How to reproduce it (as minimally and precisely as possible):

  1. Start dragging content in CodeMirror.
  2. Trigger a Snapshot Event during the drag action. (We can trigger snapshot event adjusting snapshot-threshold)
  3. Observe the cursor and scroll behavior.

Anything else we need to know?:

Environment:

  • Operating system: ALL
  • Browser and version: ALL
  • CodePair version: v0.1.20
@devleejb
Copy link
Member Author

Related to codemirror/dev#1473.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
Status: Backlog
Status: Backlog
Development

No branches or pull requests

1 participant