-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
"editor.formatOnType": true
(vscode) behaves weirdly with calls (and attributes on calls)
#16848
Comments
Relevant code is here rust-analyzer/crates/ide/src/typing.rs Lines 105 to 189 in 0dd89d7
|
@rustbot claim |
For the first issue ( rust-analyzer/crates/ide/src/typing.rs Lines 178 to 181 in 0dd89d7
For the second point (
Maybe we should identify attributes before inserting. |
I'm not sure I understand the reasoning here. Why don't we wrap just the whole expression in a statement? If the user wants more, they can move things inside the braces.
Uh, that's fun. I guess a parsing which would make more sense is to have "attribute expr" which would wrap the call expr. But ig that would make things hard elsewhere, because to check attributes you'd have to go outwards... |
That makes sense to me.
I'm not sure. Perhaps we can also directly hack here: if it is identified that the front part of expr is attr, we consider it as inserting |
rust-analyzer version: 0.4.1881-standalone (14558af 2024-03-14)
relevant settings:
"editor.formatOnType": true
code snippet to reproduce:
If I type
{
beforef();
nothing happens (well, except the{
that was typed, obv). If I type{
beforeg();
a matching}
is added but not where I'd expect:This is what I would expect to see instead:
The text was updated successfully, but these errors were encountered: