aboutsummaryrefslogtreecommitdiff
path: root/crates/assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/assists')
-rw-r--r--crates/assists/src/handlers/remove_dbg.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/assists/src/handlers/remove_dbg.rs b/crates/assists/src/handlers/remove_dbg.rs
index be3afa250..9731344b8 100644
--- a/crates/assists/src/handlers/remove_dbg.rs
+++ b/crates/assists/src/handlers/remove_dbg.rs
@@ -93,8 +93,9 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
93 if macro_contents.len() < 2 { 93 if macro_contents.len() < 2 {
94 return false; 94 return false;
95 } 95 }
96 let mut macro_contents = macro_contents.into_iter().peekable();
96 let mut unpaired_brackets_in_contents = Vec::new(); 97 let mut unpaired_brackets_in_contents = Vec::new();
97 for element in macro_contents { 98 while let Some(element) = macro_contents.next() {
98 match element.kind() { 99 match element.kind() {
99 T!['('] | T!['['] | T!['{'] => unpaired_brackets_in_contents.push(element), 100 T!['('] | T!['['] | T!['{'] => unpaired_brackets_in_contents.push(element),
100 T![')'] => { 101 T![')'] => {
@@ -118,12 +119,13 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
118 symbol_kind => { 119 symbol_kind => {
119 let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty(); 120 let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty();
120 if symbol_not_in_bracket 121 if symbol_not_in_bracket
121 // paths 122 && symbol_kind != SyntaxKind::COLON // paths
122 && symbol_kind != SyntaxKind::COLON 123 && (symbol_kind != SyntaxKind::DOT // field/method access
123 // field/method access 124 || macro_contents // range expressions consist of two SyntaxKind::Dot in macro invocations
124 && symbol_kind != SyntaxKind::DOT 125 .peek()
125 // try operator 126 .map(|element| element.kind() == SyntaxKind::DOT)
126 && symbol_kind != SyntaxKind::QUESTION 127 .unwrap_or(false))
128 && symbol_kind != SyntaxKind::QUESTION // try operator
127 && (symbol_kind.is_punct() || symbol_kind == SyntaxKind::AS_KW) 129 && (symbol_kind.is_punct() || symbol_kind == SyntaxKind::AS_KW)
128 { 130 {
129 return true; 131 return true;
@@ -347,7 +349,6 @@ fn main() {
347 } 349 }
348 350
349 #[test] 351 #[test]
350 #[ignore] // FIXME: we encounter SyntaxKind::DOT instead of SyntaxKind::DOT2 causing this to fail
351 fn test_remove_dbg_range_expr() { 352 fn test_remove_dbg_range_expr() {
352 check_assist( 353 check_assist(
353 remove_dbg, 354 remove_dbg,