-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix #10391 - incorrect cursor position after autocomplete #10647
Conversation
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks for the quick review! I fixed the tests, hope they run now. |
I don't think the fix works now. The Edit: give me a minute to confirm, maybe I had stale binder 👀 |
Yup, not working after the changes that fixed the test: Debug info: patch = {start: 5, end: 5, value: "clear"};
cursorBeforeChange = 5 this means that the condition of Also, maybe it would be useful to add a test for |
Thanks @krassowski for trying out the patch! I fixed the issue on by including the
When performing autocomplete on the empty word (e.g. "" ⇒ "dict"), the cursor is within the replaced range. Although in this case This PR only fixes an edge case. When the cursor is within the replaced word (or directly after it), we expect that the cursor is after the replaced word after the change is performed. All other cases are handled by the existing cursor mapping approach. |
7a0be5f
to
dcb00cd
Compare
I rebased because the tests were failing. Now different tests that are unrelated to this PR are failing. I'm going to try rebasing again tomorrow. |
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
@meeseeksdev please backport to 3.1.x |
… position after autocomplete
…complete (#10689) Co-authored-by: Kevin Jahns <kevin.jahns@protonmail.com>
References
This PR fixes the issue described in #10391.
Code changes
The auto-complete plugin now explicitly sets the cursor position after the replacement.
Previously, we relied on the behavior of modeldb to adapt the cursor position correctly. The autocomplete plugin simply replaced text and the local position would be automatically updated to the position after the replacement. This is no longer possible in all cases because y-codemirror now updates the cursor positions after each change with an algorithm that is designed to work nicely with remote changes. We instead update the position to the position before the replacement, because that will lead to fewer conflicts when multiple peers insert content at the same time.
User-facing changes
None
Backwards-incompatible changes
None