diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index fae259411..baf9a1b4b 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -390,26 +390,12 @@ impl ast::MatchArmList { | |||
390 | Some(t) => t, | 390 | Some(t) => t, |
391 | None => return self.clone(), | 391 | None => return self.clone(), |
392 | }; | 392 | }; |
393 | let mut sib = r_curly.prev_sibling_or_token(); | 393 | let position = InsertPosition::Before(r_curly.into()); |
394 | while let Some(s) = sib.clone() { | 394 | let arm_ws = tokens::WsBuilder::new(" "); |
395 | if let Some(tok) = s.as_token() { | 395 | let match_indent = &leading_indent(self.syntax()).unwrap_or_default(); |
396 | if tok.kind() != WHITESPACE { | 396 | let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent)); |
397 | break; | 397 | let to_insert: ArrayVec<[SyntaxElement; 3]> = |
398 | } | 398 | [arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into(); |
399 | sib = s.prev_sibling_or_token(); | ||
400 | } else { | ||
401 | break; | ||
402 | } | ||
403 | } | ||
404 | let indent = " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(); | ||
405 | let sib = match sib { | ||
406 | Some(s) => s, | ||
407 | None => return self.clone(), | ||
408 | }; | ||
409 | let position = InsertPosition::After(sib.into()); | ||
410 | let ws = tokens::WsBuilder::new(&format!("\n{}", indent)); | ||
411 | let to_insert: ArrayVec<[SyntaxElement; 2]> = | ||
412 | [ws.ws().into(), item.syntax().clone().into()].into(); | ||
413 | self.insert_children(position, to_insert) | 399 | self.insert_children(position, to_insert) |
414 | } | 400 | } |
415 | } | 401 | } |