-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Write (:w) in HTML files selects the whole file and loses position when HTML LSP is active #3859
Comments
That's because the formatting response from the LSP effectively removes the whole document then inserts the formatted document (rather than a diff) |
So is the fix not to include the formatting feature? Because this makes it unusable. |
The LSP spec allows for the language server to say what changed in the formatting response in small diffs rather than resending the whole (potentially large) document. This is similar to #2655 See also #2752 - it may happen because of line-endings of the document. If the language server is replacing CRLFs with LFs it may send the whole document, but that should be a one-time occurrence. |
Alternatively, you can specify an external formatter which Helix will generate a diff for. |
The solution is to detect a whole document replacement by the format action and run it through the same code we use for external formatters to generate a diff. |
On second thought, that sounds a little expensive. |
Ah right, we could just convert |
We only want to deal with the latter and it should be easy to detect: a single change that spans the entire document range. |
Summary
Issuing a
:w
command in an HTML file selects the whole file and loses your current position when HTML LSP is active.Reproduction Steps
I tried this:
npm i -g vscode-langservers-extracted
to install HTML LSP:w
I expected this to happen:
File is saved. Nothing is selected. My position is saved.
Instead, this happened:
File is saved. Everything is selected. My position is lost (reverts to top).
Note that this behaviour does not occur if the LSP is not installed/active.
Helix log
~/.cache/helix/helix.log
Platform
Linux (Fedora Silverblue 36)
Terminal Emulator
Black Box
Helix Version
helix 22.08.1 (714db9c)
The text was updated successfully, but these errors were encountered: