diff options
author | Jonas Schievink <[email protected]> | 2021-04-07 00:39:17 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-04-07 15:38:04 +0100 |
commit | 17a1011a12d270dfaf83a404dd7c40c5d9967064 (patch) | |
tree | 78ec654f68ef76a327412357e642083131ecf64c /crates/ide | |
parent | d75cacc601891eb89318b3c483b3fcfb0535f0f8 (diff) |
simplify
Diffstat (limited to 'crates/ide')
-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())) |