Don't keep parens around with remove-dbg when encountering method chaining
This commit is contained in:
parent
91c1af3612
commit
6675d4c576
1 changed files with 20 additions and 0 deletions
|
|
@ -119,6 +119,7 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
|
|||
let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty();
|
||||
if symbol_not_in_bracket
|
||||
&& symbol_kind != SyntaxKind::COLON
|
||||
&& symbol_kind != SyntaxKind::DOT
|
||||
&& symbol_kind.is_punct()
|
||||
{
|
||||
return true;
|
||||
|
|
@ -242,6 +243,25 @@ fn main() {
|
|||
check_assist(remove_dbg, r#"let res = <|>dbg![2 + 2] * 5"#, r#"let res = (2 + 2) * 5"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_dbg_method_chaining() {
|
||||
check_assist(
|
||||
remove_dbg,
|
||||
r#"let res = <|>dbg!(foo().bar()).baz();"#,
|
||||
r#"let res = foo().bar().baz();"#,
|
||||
);
|
||||
check_assist(
|
||||
remove_dbg,
|
||||
r#"let res = <|>dbg!(foo.bar()).baz();"#,
|
||||
r#"let res = foo.bar().baz();"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_dbg_field_chaining() {
|
||||
check_assist(remove_dbg, r#"let res = <|>dbg!(foo.bar).baz;"#, r#"let res = foo.bar.baz;"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_dbg_from_inside_fn() {
|
||||
check_assist_target(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue