@@ -424,6 +424,11 @@ public void ViCursorMovement()
424424 [ SkippableFact ]
425425 public void ViGotoBrace ( )
426426 {
427+ // NOTE: When the input has unmatched braces, in order to avoid an
428+ // exception caused by AcceptLineImpl waiting for incomplete input,
429+ // the test needs to end with the Vi command "ddi" and assert that
430+ // the result is an empty string.
431+
427432 TestSetup ( KeyMode . Vi ) ;
428433
429434 Test ( "0[2(4{6]8)a}c" , Keys (
@@ -451,25 +456,26 @@ public void ViGotoBrace()
451456 CheckThat ( ( ) => AssertCursorLeftIs ( 4 ) ) ,
452457 _ . Percent ,
453458 CheckThat ( ( ) => AssertCursorLeftIs ( 4 ) ) ,
454- "ddi"
459+ "ddi" // Unmatched brace
455460 ) ) ;
456461 }
457462
458- // tests when cursor not on any paren
463+ // Tests when the cursor is not on any paren
459464 foreach ( var ( opening , closing ) in new [ ] { ( '(' , ')' ) , ( '{' , '}' ) , ( '[' , ']' ) } )
460465 {
461- // closing paren with backward match
466+ // Closing paren with backward match
462467 string input1 = $ "0{ opening } 2{ opening } 4foo{ closing } ";
463- Test ( input1 , Keys (
468+ Test ( "" , Keys (
464469 input1 ,
465470 CheckThat ( ( ) => AssertCursorLeftIs ( 9 ) ) ,
466471 _ . Escape , CheckThat ( ( ) => AssertCursorLeftIs ( 8 ) ) ,
467472 "0ff" , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) ) ,
468473 _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 3 ) ) ,
469- _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 8 ) )
474+ _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 8 ) ) ,
475+ "ddi" // Unmatched closing brace
470476 ) ) ;
471477
472- // closing paren without backward match
478+ // Closing paren without backward match
473479 string input2 = $ "0]2)4foo{ closing } ";
474480 Test ( input2 , Keys (
475481 input2 ,
@@ -480,7 +486,7 @@ public void ViGotoBrace()
480486 _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) )
481487 ) ) ;
482488
483- // opening paren with forward match
489+ // Opening paren with forward match
484490 string input3 = $ "0{ opening } 2foo6{ closing } ";
485491 Test ( input3 , Keys (
486492 input3 ,
@@ -490,15 +496,17 @@ public void ViGotoBrace()
490496 _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 1 ) ) ,
491497 _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 7 ) )
492498 ) ) ;
493- // opening paren without forward match
499+
500+ // Opening paren without forward match
494501 string input4 = $ "0)2]4foo{ opening } (";
495- Test ( input4 , Keys (
502+ TestMustDing ( "" , Keys (
496503 input4 ,
497504 CheckThat ( ( ) => AssertCursorLeftIs ( 10 ) ) ,
498505 _ . Escape , CheckThat ( ( ) => AssertCursorLeftIs ( 9 ) ) ,
499506 "0ff" , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) ) ,
500507 _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) ) , // stay still
501- _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) )
508+ _ . Percent , CheckThat ( ( ) => AssertCursorLeftIs ( 5 ) ) ,
509+ "ddi" // Unmatched brace
502510 ) ) ;
503511 }
504512
0 commit comments