Closed jpnurmi closed 11 months ago
I thought it was somehow related to the special handling of std-widgets.slint
but actually, it happens with any type that gets auto-imported from another .slint
file. If the import already exists, then it completes fine without extra spaces and braces.
https://github.com/slint-ui/slint/assets/140617/ca6a36fe-4145-472f-9d49-9c05c4dde01c
This is the difference between https://github.com/slint-ui/slint/blob/f546d22861af3199b801c77185b59b2a52906c3d/tools/lsp/language/completion.rs#L76 and https://github.com/slint-ui/slint/blob/f546d22861af3199b801c77185b59b2a52906c3d/tools/lsp/language/completion.rs#L667
It used to be consistant but the spaces were removed in one case: https://github.com/slint-ui/slint/commit/839b5e8ee66de3ace208ac1b3bde9156599b2c38
Thanks, that helped with the indentation. It should also check if the token is already followed by a brace to avoid inserting extra braces when using the "Wrap in element" action:
VerticalBox·{}·{
····Rectangle·{}
}
In VS Code, auto-completion behaves differently for built-in types and std-widgets. Both place the cursor between the curly braces but when auto-completing std-widgets, there are extra spaces around.
Rectangle·{|}
VerticalLayout·{|}
vs.ScrollView·{·|·}
VerticalLayout·{·|·}
The problem is that after hitting enter, the extra whitespace is left around i.e. there's a trailing space after the opening brace, and the closing brace is indented off by one space.
When wrapping in elements and auto-completing the element type in snippet mode, built-in elements behave correctly but for std-widgets, it inserts extra braces.
With the following starting point: