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

Add keyboard shortcut for formatting and preserve cursor position #969

Open
fhammerschmidt opened this issue Feb 11, 2025 · 1 comment
Open
Assignees

Comments

@fhammerschmidt
Copy link
Member

fhammerschmidt commented Feb 11, 2025

Add a keyboard shortcut for formatting.

Currently, the cursor position gets lost after pressing it, which makes this feel very awkward. Try to preserve it.

This might only be solved by upgrading to CodeMirror 6 (https://codemirror.net/docs/migration/), which utilizes offsets instead of line coordinates.

@fhammerschmidt fhammerschmidt changed the title Preserve cursor position after formatting Add keyboard shortcut for formatting and preserve cursor position Feb 11, 2025
@tsnobip
Copy link
Contributor

tsnobip commented Feb 11, 2025

the solution is likely to wrap code formatting into a transaction that'd calculate a diff between the old and the new code and let code mirror calculate the new position of the cursor accordingly.
https://discuss.codemirror.net/t/how-to-map-cursor-position-after-formatting-code/6267/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants