diff options
Diffstat (limited to 'crates/ra_ide_api_light/src')
-rw-r--r-- | crates/ra_ide_api_light/src/join_lines.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/crates/ra_ide_api_light/src/join_lines.rs b/crates/ra_ide_api_light/src/join_lines.rs index 9a400199f..b5bcd62fb 100644 --- a/crates/ra_ide_api_light/src/join_lines.rs +++ b/crates/ra_ide_api_light/src/join_lines.rs | |||
@@ -2,8 +2,9 @@ use itertools::Itertools; | |||
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | SourceFile, TextRange, TextUnit, AstNode, SyntaxNode, | 3 | SourceFile, TextRange, TextUnit, AstNode, SyntaxNode, |
4 | SyntaxKind::{self, WHITESPACE, COMMA, R_CURLY, R_PAREN, R_BRACK}, | 4 | SyntaxKind::{self, WHITESPACE, COMMA, R_CURLY, R_PAREN, R_BRACK}, |
5 | algo::find_covering_node, | 5 | algo::{find_covering_node, non_trivia_sibling}, |
6 | ast, | 6 | ast, |
7 | Direction, | ||
7 | }; | 8 | }; |
8 | use ra_fmt::{ | 9 | use ra_fmt::{ |
9 | compute_ws, extract_trivial_expression | 10 | compute_ws, extract_trivial_expression |
@@ -121,13 +122,8 @@ fn remove_newline( | |||
121 | } | 122 | } |
122 | 123 | ||
123 | fn has_comma_after(node: &SyntaxNode) -> bool { | 124 | fn has_comma_after(node: &SyntaxNode) -> bool { |
124 | let next = node.next_sibling(); | 125 | match non_trivia_sibling(node, Direction::Next) { |
125 | let nnext = node.next_sibling().and_then(|n| n.next_sibling()); | 126 | Some(n) => n.kind() == COMMA, |
126 | |||
127 | match (next, nnext) { | ||
128 | // Whitespace followed by a comma is fine | ||
129 | (Some(ws), Some(comma)) if ws.kind() == WHITESPACE && comma.kind() == COMMA => true, | ||
130 | (Some(n), _) => n.kind() == COMMA, | ||
131 | _ => false, | 127 | _ => false, |
132 | } | 128 | } |
133 | } | 129 | } |