@@ -111,7 +111,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange>
111
111
Some ( SingleFileChange {
112
112
label : "reindent dot" . to_string ( ) ,
113
113
edit : TextEdit :: replace ( TextRange :: new ( offset - current_indent_len, offset) , target_indent) ,
114
- cursor_position : Some ( offset + target_indent_len - current_indent_len + TextSize :: of ( '.' ) ) ,
114
+ cursor_position : None ,
115
115
} )
116
116
}
117
117
@@ -130,7 +130,7 @@ fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChang
130
130
Some ( SingleFileChange {
131
131
label : "add space after return type" . to_string ( ) ,
132
132
edit : TextEdit :: insert ( after_arrow, " " . to_string ( ) ) ,
133
- cursor_position : Some ( after_arrow ) ,
133
+ cursor_position : None ,
134
134
} )
135
135
}
136
136
@@ -140,29 +140,23 @@ mod tests {
140
140
141
141
use super :: * ;
142
142
143
- fn do_type_char ( char_typed : char , before : & str ) -> Option < ( String , SingleFileChange ) > {
143
+ fn do_type_char ( char_typed : char , before : & str ) -> Option < String > {
144
144
let ( offset, before) = extract_offset ( before) ;
145
145
let edit = TextEdit :: insert ( offset, char_typed. to_string ( ) ) ;
146
146
let mut before = before. to_string ( ) ;
147
147
edit. apply ( & mut before) ;
148
148
let parse = SourceFile :: parse ( & before) ;
149
149
on_char_typed_inner ( & parse. tree ( ) , offset, char_typed) . map ( |it| {
150
150
it. edit . apply ( & mut before) ;
151
- ( before. to_string ( ) , it )
151
+ before. to_string ( )
152
152
} )
153
153
}
154
154
155
155
fn type_char ( char_typed : char , before : & str , after : & str ) {
156
- let ( actual, file_change ) = do_type_char ( char_typed, before)
156
+ let actual = do_type_char ( char_typed, before)
157
157
. unwrap_or_else ( || panic ! ( "typing `{}` did nothing" , char_typed) ) ;
158
158
159
- if after. contains ( "<|>" ) {
160
- let ( offset, after) = extract_offset ( after) ;
161
- assert_eq_text ! ( & after, & actual) ;
162
- assert_eq ! ( file_change. cursor_position, Some ( offset) )
163
- } else {
164
- assert_eq_text ! ( after, & actual) ;
165
- }
159
+ assert_eq_text ! ( after, & actual) ;
166
160
}
167
161
168
162
fn type_char_noop ( char_typed : char , before : & str ) {
@@ -350,6 +344,6 @@ fn foo() {
350
344
351
345
#[ test]
352
346
fn adds_space_after_return_type ( ) {
353
- type_char ( '>' , "fn foo() -<|>{ 92 }" , "fn foo() -><|> { 92 }" )
347
+ type_char ( '>' , "fn foo() -<|>{ 92 }" , "fn foo() -> { 92 }" )
354
348
}
355
349
}
0 commit comments