Open skondrashov opened 3 years ago
Do you also see that when running cargo fmt
?
@lnicola No, cargo fmt works fine (just strips the whitespace). That runs rustfmt, right? I opened an issue on their board initially because I thought it was their issue, but then they rightly said it was not, and I can't figure out what's causing it. I have yet to replicate it with a terminal command.
Yeah, I tried to reproduce it, but thought you might have a different rustfmt
version.
I'm not sure why RLS would do this -- I thought it links to the rustfmt
crate, but I might be wrong.
I just tried out of curiosity, and if you have "trim trailing whitespace" on in the vscode settings, this won't happen, since it trims the whitespace first before running whatever formatter (which is also a nice workaround for me to use :p)
Yeah, that's a good workaround.
But may I suggest giving https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer a spin? It does have some limitations, but some users are quite happy with it (and it auto-formats by running rustfmt
, for better or worse).
I used rust-analyzer before, and I don't remember why I switched. I do just want to support the most popular extension because it's a barrier to entry if the default option for new Rust developers is just worse... I'm a little confused why you'd recommend not using the extension as a solution to the issue, are you not affiliated with this project?
I'm a little confused why you'd recommend not using the extension as a solution to the issue, are you not affiliated with this project?
I'm a rust-analyzer
contributor. More often than not I refrain to advertise it, but on the other hand, a lot of new users have trouble with vscode-rust
and don't necessarily realize there's an alternative.
rust-analyzer
will replace RLS "some day", and currently has a more regular release schedule. Of course, it might not work well for you, but if that's the case please file an issue.
I guess we're both looking for the same thing, I'll try rust-analyzer and contribute feedback there if I figure out why I moved away in the first place. This issue certainly doesn't happen there. Thanks!
Something like:
With a space on line 2, line 2 gets removed, but without a space, it stays. I'm not entirely sure what tool this issues is related to but it's very easy to reproduce on my setup and it seems I'm just using this extension to format and nothing else.