-
Notifications
You must be signed in to change notification settings - Fork 644
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 fixes and improvements #4625
Conversation
For more control over whitespace
Trailing comma in array is usually handled by formatters by formatting the array with lines instead of spaces.
where large means >= 80
should fix everything in #3900 |
That sounds super promising ❤️❤️. Looking forward to trying this out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
This definitively improves things.
I left a few comments for things that could be done in follow up.
&& whitespace_to(&mut sub, SyntaxKind::LBracket, writer, state, " ")?; | ||
|
||
if !ok { | ||
eprintln!("Inconsistency: Expect states and ']'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should get rid of these warnings.
They'd be shown in the Slint LSP output tab in vscode and maybe other editors also show it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it will make these function a bit more flexible. Currently they just error out
animate background { | ||
duration: 800ms; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like when it is in one single line. Perhaps we could have the same trick as array, if it is fitting in 80 character it shouldn't be formatted in several lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next pr, I have changed it so that if there is only binding it will be kept on a single line, but with multiple it is broken into multiple lines.
But I can change it to 80 char limit too if that's better.
} else { | ||
(SyntaxKind::Identifier, " ") | ||
}; | ||
let el = whitespace_to_one_of(&mut sub, &[kind], writer, state, prefix_whitespace)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess you can just call whitespace_to here. In fact i'd do it in the if above.
Can you also check for [index] in model
without an name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also check for [index] in model without an name?
Typing that out results in a compiler error with 1.4.0, is this a new syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it was allowed (i remember wanting this to be allowed while parsing for
expressions:
slint/internal/compiler/parser/element.rs
Line 148 in 1d987a4
/// for [idx] in mm: Elem { } |
But it's actually indeed not accepted, you're right
for
with index no longer errors out and is formatted properlyWith these patches I can run
slint-lsp format
on slint files in examples and the result seems to be acceptable.Closes #3900