diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/typing.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs index c1bdc51b0..391a8e867 100644 --- a/crates/ide/src/typing.rs +++ b/crates/ide/src/typing.rs | |||
@@ -85,15 +85,13 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi | |||
85 | 85 | ||
86 | // We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as | 86 | // We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as |
87 | // either the trailing expr or an ExprStmt. | 87 | // either the trailing expr or an ExprStmt. |
88 | let offset = { | 88 | let offset = match block.statements().next() { |
89 | match block.statements().next() { | 89 | Some(ast::Stmt::ExprStmt(it)) => { |
90 | Some(ast::Stmt::ExprStmt(it)) => { | 90 | // Use the expression span to place `}` before the `;` |
91 | // Use the expression span to place `}` before the `;` | 91 | it.expr()?.syntax().text_range().end() |
92 | it.expr()?.syntax().text_range().end() | ||
93 | } | ||
94 | None => block.tail_expr()?.syntax().text_range().end(), | ||
95 | _ => return None, | ||
96 | } | 92 | } |
93 | None => block.tail_expr()?.syntax().text_range().end(), | ||
94 | _ => return None, | ||
97 | }; | 95 | }; |
98 | 96 | ||
99 | Some(TextEdit::insert(offset, "}".to_string())) | 97 | Some(TextEdit::insert(offset, "}".to_string())) |