@@ -625,4 +625,48 @@ suite('Mode Insert', () => {
625
625
endMode : Mode . Insert ,
626
626
} ) ;
627
627
} ) ;
628
+
629
+ suite ( 'VSCode auto-surround' , ( ) => {
630
+ test ( 'preserves selection' , async ( ) => {
631
+ await modeHandler . handleMultipleKeyEvents ( [ 'i' , 's' , 'e' , 'l' , 'e' , 'c' , 't' ] ) ;
632
+ await vscode . commands . executeCommand ( 'editor.action.selectAll' ) ;
633
+ await modeHandler . handleKeyEvent ( '"' ) ;
634
+ assertEqualLines ( [ '"select"' ] ) ;
635
+ assert . strictEqual ( modeHandler . currentMode , Mode . Insert ) ;
636
+ assert . strictEqual ( vscode . window . activeTextEditor ! . selection . start . character , 1 ) ;
637
+ assert . strictEqual ( vscode . window . activeTextEditor ! . selection . end . character , 7 ) ;
638
+ } ) ;
639
+
640
+ test ( 'replaces selection' , async ( ) => {
641
+ await modeHandler . handleMultipleKeyEvents ( [ 'i' , 't' , 'e' , 'm' , 'p' ] ) ;
642
+ await vscode . commands . executeCommand ( 'editor.action.selectAll' ) ;
643
+ await modeHandler . handleMultipleKeyEvents ( [ '"' , 'f' , 'i' , 'n' , 'a' , 'l' ] ) ;
644
+ assertEqualLines ( [ '"final"' ] ) ;
645
+ assert . strictEqual ( modeHandler . currentMode , Mode . Insert ) ;
646
+ assert . strictEqual ( vscode . window . activeTextEditor ! . selection . start . character , 6 ) ;
647
+ assert . strictEqual ( vscode . window . activeTextEditor ! . selection . end . character , 6 ) ;
648
+ } ) ;
649
+
650
+ test ( 'stacks' , async ( ) => {
651
+ await modeHandler . handleMultipleKeyEvents ( [ 'i' , 't' , 'e' , 'x' , 't' ] ) ;
652
+ await vscode . commands . executeCommand ( 'editor.action.selectAll' ) ;
653
+
654
+ await modeHandler . handleMultipleKeyEvents ( [ '"' , "'" , '(' , '[' , '{' , '<' , '`' ] ) ;
655
+ assertEqualLines ( [ '"\'([{<`text`>}])\'"' ] ) ;
656
+ } ) ;
657
+
658
+ test ( 'handles snippet' , async ( ) => {
659
+ await modeHandler . handleKeyEvent ( 'i' ) ;
660
+ await vscode . commands . executeCommand ( 'editor.action.insertSnippet' , {
661
+ snippet : '${3:foo} ${1:bar} ${2:baz}' ,
662
+ } ) ;
663
+ await modeHandler . handleMultipleKeyEvents ( [ '(' , 'o' , 'n' , 'e' ] ) ;
664
+ await vscode . commands . executeCommand ( 'jumpToNextSnippetPlaceholder' ) ;
665
+ await modeHandler . handleMultipleKeyEvents ( [ '<' , 't' , 'w' , 'o' ] ) ;
666
+ await vscode . commands . executeCommand ( 'jumpToNextSnippetPlaceholder' ) ;
667
+ await modeHandler . handleKeyEvent ( '`' ) ;
668
+ assertEqualLines ( [ '`foo` (one) <two>' ] ) ;
669
+ assert . strictEqual ( modeHandler . currentMode , Mode . Insert ) ;
670
+ } ) ;
671
+ } ) ;
628
672
} ) ;
0 commit comments