Skip to content

Commit

Permalink
fmt: Add space before brace in void functions
Browse files Browse the repository at this point in the history
  • Loading branch information
elipsitz authored and ogoffart committed Mar 27, 2024
1 parent aab2bd2 commit 72ca5f4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/lsp/fmt/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ fn format_function(
fold(n, writer, state)?;
whitespace_to(&mut sub, SyntaxKind::ReturnType, writer, state, " ")?;
}
SyntaxKind::CodeBlock => {
state.insert_whitespace(" ");
fold(n, writer, state)?;
}
_ => {
fold(n, writer, state)?;
}
Expand Down Expand Up @@ -714,12 +718,8 @@ fn format_codeblock(
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();
let prefix_whitespace = if prev_is_return_type { " " } else { "" };
if !whitespace_to(&mut sub, SyntaxKind::LBrace, writer, state, prefix_whitespace)? {
if !whitespace_to(&mut sub, SyntaxKind::LBrace, writer, state, "")? {
finish_node(sub, writer, state)?;
return Ok(());
}
Expand Down Expand Up @@ -1991,7 +1991,7 @@ export component MainWindow2 inherits Rectangle {
}
return x;
}
function a(){
function a() {
/* ddd */}
}
"#,
Expand Down

0 comments on commit 72ca5f4

Please sign in to comment.