-
Notifications
You must be signed in to change notification settings - Fork 46
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
Formatting replaces the entire file #383
Comments
I think that imara-diff can be used to actually calculate the regions that have changed: https://docs.rs/imara-diff/0.1.5/imara_diff/sink/trait.Sink.html |
The format returned by https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textEdit Basically it is a matter of getting the ranges from the diff, and then serialising those as a |
Huh, looking at the source in I wonder if the root cause of the issue that I'm seeing is something else then. |
Thanks for providing the reproduction steps! I might be doing something wrong here but I'm unable to reproduce this in the way you've described in the "Reproduction steps" section. I've attached a screen recording of the same. Can you verify if that's what you intended on doing? I'm using the Screen.Recording.2024-02-12.at.11.55.52.mov |
@WhyNotHugo what LSP version are you using? I'm asking because the narrow edits feature has only been released with v0.0.52 |
When formatting a file,
ruff
will replace the entire file with a formatted copy. It should only replace lines that have changed (as far as I can tell, this is what most LSPs do).The issue with replacing the whole file, is that (at least on neovim) the cursor position is reset to the beginning of the file on background windows/splits, because the entire file was deleted/replaced.
Reproduction steps
:vsp
)The cursor for the second split will now jump to the top of the file.
The text was updated successfully, but these errors were encountered: