@@ -501,3 +501,52 @@ add_task(async function test_normal_caret() {
501501 await test_motion ( "^" , 2 , "h" ) ;
502502 } ) ;
503503} ) ;
504+
505+ add_task ( async function test_normal_percent ( ) {
506+ await BrowserTestUtils . withNewTab ( INPUT_TEST_FILE , async browser => {
507+ const { set_text, test_motion, set_selection } = GlideTestUtils . make_input_test_helpers ( browser , { text_start : 1 } ) ;
508+
509+ await set_text ( "a(b)c" , "open paren to close" ) ;
510+ await set_selection ( 1 , "(" ) ;
511+ await test_motion ( "%" , 3 , ")" ) ;
512+
513+ await set_text ( "a(b)c" , "close paren to open" ) ;
514+ await set_selection ( 3 , ")" ) ;
515+ await test_motion ( "%" , 1 , "(" ) ;
516+
517+ await set_text ( "((x))" , "nested parens from outer open" ) ;
518+ await set_selection ( 0 , "(" ) ;
519+ await test_motion ( "%" , 4 , ")" ) ;
520+
521+ await set_text ( "((x))" , "nested parens from inner open" ) ;
522+ await set_selection ( 1 , "(" ) ;
523+ await test_motion ( "%" , 3 , ")" ) ;
524+
525+ await set_text ( "((x))" , "nested parens from final close" ) ;
526+ await set_selection ( 4 , ")" ) ;
527+ await test_motion ( "%" , 0 , "(" ) ;
528+
529+ await set_text ( "[a]" , "square brackets" ) ;
530+ await set_selection ( 0 , "[" ) ;
531+ await test_motion ( "%" , 2 , "]" ) ;
532+
533+ await set_text ( "{a}" , "curly brackets" ) ;
534+ await set_selection ( 0 , "{" ) ;
535+ await test_motion ( "%" , 2 , "}" ) ;
536+
537+ await set_text ( "(\n)" , "multiline pair" ) ;
538+ await set_selection ( 0 , "(" ) ;
539+ await test_motion ( "%" , 2 , ")" ) ;
540+
541+ await set_text ( "a (b)" , "text before open paren, jump to close" ) ;
542+ await set_selection ( 0 , "a" ) ;
543+ await test_motion ( "%" , 4 , ")" ) ;
544+
545+ await set_text ( "abc" , "no bracket on rest of line" ) ;
546+ await test_motion ( "%" , 0 , "a" ) ;
547+
548+ await set_text ( "abc(de" , "unbalanced bracket on line" ) ;
549+ await set_selection ( 3 , "(" ) ;
550+ await test_motion ( "%" , 3 , "(" ) ;
551+ } ) ;
552+ } ) ;
0 commit comments