File tree 1 file changed +31
-20
lines changed
1 file changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,10 @@ fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
253
253
if file. syntax ( ) . text ( ) . slice ( offset..expr_range. start ( ) ) . contains_char ( '\n' ) {
254
254
return None ;
255
255
}
256
+ // Good indicator that we will insert into a bad spot, so bail out.
257
+ if expr. syntax ( ) . descendants ( ) . any ( |it| it. kind ( ) == SyntaxKind :: ERROR ) {
258
+ return None ;
259
+ }
256
260
let offset = let_stmt. syntax ( ) . text_range ( ) . end ( ) ;
257
261
Some ( TextEdit :: insert ( offset, ";" . to_string ( ) ) )
258
262
}
@@ -407,15 +411,14 @@ mod tests {
407
411
408
412
#[ test]
409
413
fn test_semi_after_let ( ) {
410
- // do_check(r"
411
- // fn foo() {
412
- // let foo =$0
413
- // }
414
- // ", r"
415
- // fn foo() {
416
- // let foo =;
417
- // }
418
- // ");
414
+ type_char_noop (
415
+ '=' ,
416
+ r"
417
+ fn foo() {
418
+ let foo =$0
419
+ }
420
+ " ,
421
+ ) ;
419
422
type_char (
420
423
'=' ,
421
424
r#"
@@ -429,17 +432,25 @@ fn foo() {
429
432
}
430
433
"# ,
431
434
) ;
432
- // do_check(r"
433
- // fn foo() {
434
- // let foo =$0
435
- // let bar = 1;
436
- // }
437
- // ", r"
438
- // fn foo() {
439
- // let foo =;
440
- // let bar = 1;
441
- // }
442
- // ");
435
+ type_char_noop (
436
+ '=' ,
437
+ r#"
438
+ fn foo() {
439
+ let difference $0(counts: &HashMap<(char, char), u64>, last: char) -> u64 {
440
+ // ...
441
+ }
442
+ }
443
+ "# ,
444
+ ) ;
445
+ type_char_noop (
446
+ '=' ,
447
+ r"
448
+ fn foo() {
449
+ let foo =$0
450
+ let bar = 1;
451
+ }
452
+ " ,
453
+ ) ;
443
454
}
444
455
445
456
#[ test]
You can’t perform that action at this time.
0 commit comments