-
Notifications
You must be signed in to change notification settings - Fork 164
format document sometimes ignored #65
Comments
Looking at the "Rust Language Server" output, I get:
As this file builds correctly, not sure what would fail formatting. |
@jonathandturner I've had that happen where some of the lines in the file exceeded the default |
Ah, that's an interesting clue - rustfmt is meant to work as a checker too, so if a line fails the width constraint it sets the exit code to a failure code. I wonder if the RLS is interpreting that as failure to run. |
When I use the VSCode Format Document command on a file that is already formatted, I get no error. If I add a line with just comment characters that exceeds the max_width setting in my rustfmt.toml by one, I get this error:
If I reduce the number of characters on that line by one, I get no error. |
rustfmt reports the error reasonably well:
But I guess rls doesn't parse that and just looks at the exit code. |
IMHO, linters and formatters should be separate tools. rustfmt should be reformatting the file to achieve the max_width setting, not simply aborting when a line exceeds that max. |
I take that back. It seems to only fail with that error when it can't reformat the line to reduce it below max_width. If I make a fn declaration with a long list of parameters that extends past the max_width, rustfmt will reformat the declaration to chop down, without reporting that error. |
cc rust-lang/rustfmt#1977 (because we seem to need to check the exit code better in the RLS) |
I get the same -32603 error code when I start a multi-line comment followed by a space and a newline. Deleting the space gets it working again. I'm on the beta channel since I couldn't get rls-preview on nightly, so I'm not sure if this is still an issue. |
Not only does the format fail, RLS crashes and rls-vscode fails to restart it. At the very least can that bit be made robust? |
@DanielJoyce do you have a test case which reproduces this reliably? I'd like to look into this. |
This should be fixed now that we've changed the rustfmt exit codes. |
Added docstrings based on the language server protocol to …
I have two files in my project, main.rs and other.rs.
If I do 'format document' on my other.rs, it works fine. If, instead, I do format document on my main.rs, it doesn't do anything and leaves the file as is (complete with trailing spaces).
The text was updated successfully, but these errors were encountered: