diff options
Diffstat (limited to 'crates/libeditor/src/typing.rs')
-rw-r--r-- | crates/libeditor/src/typing.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs index 3a3776c26..daa57983f 100644 --- a/crates/libeditor/src/typing.rs +++ b/crates/libeditor/src/typing.rs | |||
@@ -84,7 +84,7 @@ fn remove_newline( | |||
84 | offset: TextUnit, | 84 | offset: TextUnit, |
85 | ) { | 85 | ) { |
86 | if node.kind() == WHITESPACE && node_text.bytes().filter(|&b| b == b'\n').count() == 1 { | 86 | if node.kind() == WHITESPACE && node_text.bytes().filter(|&b| b == b'\n').count() == 1 { |
87 | if join_lambda_body(edit, node).is_some() { | 87 | if join_single_expr_block(edit, node).is_some() { |
88 | return | 88 | return |
89 | } | 89 | } |
90 | match (node.prev_sibling(), node.next_sibling()) { | 90 | match (node.prev_sibling(), node.next_sibling()) { |
@@ -118,13 +118,12 @@ fn remove_newline( | |||
118 | ); | 118 | ); |
119 | } | 119 | } |
120 | 120 | ||
121 | fn join_lambda_body( | 121 | fn join_single_expr_block( |
122 | edit: &mut EditBuilder, | 122 | edit: &mut EditBuilder, |
123 | node: SyntaxNodeRef, | 123 | node: SyntaxNodeRef, |
124 | ) -> Option<()> { | 124 | ) -> Option<()> { |
125 | let block = ast::Block::cast(node.parent()?)?; | 125 | let block = ast::Block::cast(node.parent()?)?; |
126 | let block_expr = ast::BlockExpr::cast(block.syntax().parent()?)?; | 126 | let block_expr = ast::BlockExpr::cast(block.syntax().parent()?)?; |
127 | let _lambda = ast::LambdaExpr::cast(block_expr.syntax().parent()?)?; | ||
128 | let expr = single_expr(block)?; | 127 | let expr = single_expr(block)?; |
129 | edit.replace( | 128 | edit.replace( |
130 | block_expr.syntax().range(), | 129 | block_expr.syntax().range(), |