Skip to content

Commit e5c1c8c

Browse files
bors[bot]matklad
andauthored
Merge #9490
9490: minor: untangle complex condition r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 13161ab + c4d2671 commit e5c1c8c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/syntax/src/ted.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,17 @@ pub fn append_child_raw(node: &(impl Into<SyntaxNode> + Clone), child: impl Elem
150150
fn ws_before(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {
151151
let prev = match &position.repr {
152152
PositionRepr::FirstChild(_) => return None,
153-
PositionRepr::After(it) if it.kind() == SyntaxKind::L_CURLY => {
154-
if new.kind() == SyntaxKind::USE {
155-
if let Some(item_list) = it.parent().and_then(ast::ItemList::cast) {
156-
let mut indent = IndentLevel::from_element(&item_list.syntax().clone().into());
157-
indent.0 += 1;
158-
return Some(make::tokens::whitespace(&format!("\n{}", indent)));
159-
}
160-
}
161-
it
162-
}
163153
PositionRepr::After(it) => it,
164154
};
155+
156+
if prev.kind() == T!['{'] && new.kind() == SyntaxKind::USE {
157+
if let Some(item_list) = prev.parent().and_then(ast::ItemList::cast) {
158+
let mut indent = IndentLevel::from_element(&item_list.syntax().clone().into());
159+
indent.0 += 1;
160+
return Some(make::tokens::whitespace(&format!("\n{}", indent)));
161+
}
162+
}
163+
165164
ws_between(prev, new)
166165
}
167166
fn ws_after(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {

0 commit comments

Comments
 (0)