From c4d2671767c0b8c8b8770b6628656d2e54af2e41 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Jul 2021 17:32:59 +0300 Subject: [PATCH] minor: untangle complex condition --- crates/syntax/src/ted.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/syntax/src/ted.rs b/crates/syntax/src/ted.rs index ae970f44f16..aee90d3574b 100644 --- a/crates/syntax/src/ted.rs +++ b/crates/syntax/src/ted.rs @@ -150,18 +150,17 @@ pub fn append_child_raw(node: &(impl Into + Clone), child: impl Elem fn ws_before(position: &Position, new: &SyntaxElement) -> Option { let prev = match &position.repr { PositionRepr::FirstChild(_) => return None, - PositionRepr::After(it) if it.kind() == SyntaxKind::L_CURLY => { - if new.kind() == SyntaxKind::USE { - if let Some(item_list) = it.parent().and_then(ast::ItemList::cast) { - let mut indent = IndentLevel::from_element(&item_list.syntax().clone().into()); - indent.0 += 1; - return Some(make::tokens::whitespace(&format!("\n{}", indent))); - } - } - it - } PositionRepr::After(it) => it, }; + + if prev.kind() == T!['{'] && new.kind() == SyntaxKind::USE { + if let Some(item_list) = prev.parent().and_then(ast::ItemList::cast) { + let mut indent = IndentLevel::from_element(&item_list.syntax().clone().into()); + indent.0 += 1; + return Some(make::tokens::whitespace(&format!("\n{}", indent))); + } + } + ws_between(prev, new) } fn ws_after(position: &Position, new: &SyntaxElement) -> Option {