mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
minor: untangle complex condition
This commit is contained in:
parent
13161ab738
commit
c4d2671767
1 changed files with 9 additions and 10 deletions
|
@ -150,18 +150,17 @@ pub fn append_child_raw(node: &(impl Into<SyntaxNode> + Clone), child: impl Elem
|
||||||
fn ws_before(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {
|
fn ws_before(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {
|
||||||
let prev = match &position.repr {
|
let prev = match &position.repr {
|
||||||
PositionRepr::FirstChild(_) => return None,
|
PositionRepr::FirstChild(_) => return None,
|
||||||
PositionRepr::After(it) if it.kind() == SyntaxKind::L_CURLY => {
|
PositionRepr::After(it) => it,
|
||||||
if new.kind() == SyntaxKind::USE {
|
};
|
||||||
if let Some(item_list) = it.parent().and_then(ast::ItemList::cast) {
|
|
||||||
|
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());
|
let mut indent = IndentLevel::from_element(&item_list.syntax().clone().into());
|
||||||
indent.0 += 1;
|
indent.0 += 1;
|
||||||
return Some(make::tokens::whitespace(&format!("\n{}", indent)));
|
return Some(make::tokens::whitespace(&format!("\n{}", indent)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it
|
|
||||||
}
|
|
||||||
PositionRepr::After(it) => it,
|
|
||||||
};
|
|
||||||
ws_between(prev, new)
|
ws_between(prev, new)
|
||||||
}
|
}
|
||||||
fn ws_after(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {
|
fn ws_after(position: &Position, new: &SyntaxElement) -> Option<SyntaxToken> {
|
||||||
|
|
Loading…
Reference in a new issue