This commit is contained in:
Jonas Schievink 2021-04-07 01:39:17 +02:00
parent d75cacc601
commit 17a1011a12

View file

@ -85,15 +85,13 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
// We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as // We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as
// either the trailing expr or an ExprStmt. // either the trailing expr or an ExprStmt.
let offset = { let offset = match block.statements().next() {
match block.statements().next() {
Some(ast::Stmt::ExprStmt(it)) => { Some(ast::Stmt::ExprStmt(it)) => {
// Use the expression span to place `}` before the `;` // Use the expression span to place `}` before the `;`
it.expr()?.syntax().text_range().end() it.expr()?.syntax().text_range().end()
} }
None => block.tail_expr()?.syntax().text_range().end(), None => block.tail_expr()?.syntax().text_range().end(),
_ => return None, _ => return None,
}
}; };
Some(TextEdit::insert(offset, "}".to_string())) Some(TextEdit::insert(offset, "}".to_string()))