@@ -66,7 +66,9 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU
66
66
if is_trailing_comma ( prev. kind ( ) , next. kind ( ) ) {
67
67
// Removes: trailing comma, newline (incl. surrounding whitespace)
68
68
edit. delete ( TextRange :: from_to ( prev. text_range ( ) . start ( ) , token. text_range ( ) . end ( ) ) ) ;
69
- } else if prev. kind ( ) == T ! [ , ] && next. kind ( ) == T ! [ '}' ] {
69
+ return ;
70
+ }
71
+ if prev. kind ( ) == T ! [ , ] && next. kind ( ) == T ! [ '}' ] {
70
72
// Removes: comma, newline (incl. surrounding whitespace)
71
73
let space = if let Some ( left) = prev. prev_sibling_or_token ( ) {
72
74
compute_ws ( left. kind ( ) , next. kind ( ) )
@@ -77,7 +79,10 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU
77
79
TextRange :: from_to ( prev. text_range ( ) . start ( ) , token. text_range ( ) . end ( ) ) ,
78
80
space. to_string ( ) ,
79
81
) ;
80
- } else if let ( Some ( _) , Some ( next) ) = (
82
+ return ;
83
+ }
84
+
85
+ if let ( Some ( _) , Some ( next) ) = (
81
86
prev. as_token ( ) . cloned ( ) . and_then ( ast:: Comment :: cast) ,
82
87
next. as_token ( ) . cloned ( ) . and_then ( ast:: Comment :: cast) ,
83
88
) {
@@ -86,33 +91,34 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU
86
91
token. text_range ( ) . start ( ) ,
87
92
next. syntax ( ) . text_range ( ) . start ( ) + TextUnit :: of_str ( next. prefix ( ) ) ,
88
93
) ) ;
89
- } else {
90
- // Special case that turns something like:
91
- //
92
- // ```
93
- // my_function({<|>
94
- // <some-expr>
95
- // })
96
- // ```
97
- //
98
- // into `my_function(<some-expr>)`
99
- if join_single_expr_block ( edit, token) . is_some ( ) {
100
- return ;
101
- }
102
- // ditto for
103
- //
104
- // ```
105
- // use foo::{<|>
106
- // bar
107
- // };
108
- // ```
109
- if join_single_use_tree ( edit, token) . is_some ( ) {
110
- return ;
111
- }
94
+ return ;
95
+ }
112
96
113
- // Remove newline but add a computed amount of whitespace characters
114
- edit. replace ( token. text_range ( ) , compute_ws ( prev. kind ( ) , next. kind ( ) ) . to_string ( ) ) ;
97
+ // Special case that turns something like:
98
+ //
99
+ // ```
100
+ // my_function({<|>
101
+ // <some-expr>
102
+ // })
103
+ // ```
104
+ //
105
+ // into `my_function(<some-expr>)`
106
+ if join_single_expr_block ( edit, token) . is_some ( ) {
107
+ return ;
115
108
}
109
+ // ditto for
110
+ //
111
+ // ```
112
+ // use foo::{<|>
113
+ // bar
114
+ // };
115
+ // ```
116
+ if join_single_use_tree ( edit, token) . is_some ( ) {
117
+ return ;
118
+ }
119
+
120
+ // Remove newline but add a computed amount of whitespace characters
121
+ edit. replace ( token. text_range ( ) , compute_ws ( prev. kind ( ) , next. kind ( ) ) . to_string ( ) ) ;
116
122
}
117
123
118
124
fn has_comma_after ( node : & SyntaxNode ) -> bool {
0 commit comments