Skip to content

Commit

Permalink
fmt: Fix no whitespace after function return_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Waqar144 authored and ogoffart committed Feb 15, 2024
1 parent 05fb6d0 commit f23c768
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/lsp/fmt/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,13 @@ fn format_codeblock(
// empty CodeBlock happens when there is no `else` for example
return Ok(());
}

let prev_is_return_type =
node.prev_sibling().map(|s| s.kind() == SyntaxKind::ReturnType).unwrap_or(false);

let mut sub = node.children_with_tokens();
if !whitespace_to(&mut sub, SyntaxKind::LBrace, writer, state, "")? {
let prefix_whitespace = if prev_is_return_type { " " } else { "" };
if !whitespace_to(&mut sub, SyntaxKind::LBrace, writer, state, prefix_whitespace)? {
finish_node(sub, writer, state)?;
return Ok(());
}
Expand Down Expand Up @@ -1193,7 +1198,7 @@ component ABC {
r#"
component ABC {
in-out property <bool> logged_in: false;
function clicked() -> bool{
function clicked() -> bool {
if (logged_in) {
logged_in = false;
return true;
Expand Down

0 comments on commit f23c768

Please sign in to comment.