@@ -4479,6 +4479,37 @@ testVim('ex_api_test', function(cm, vim, helpers) {
44794479 is ( res , 'Mapping to key failed' ) ;
44804480 CodeMirror . Vim . mapclear ( ) ;
44814481} ) ;
4482+ // Testing ex-commands with non-alpha names.
4483+ testVim ( 'ex_special_names' , function ( cm , vim , helpers ) {
4484+ var ran , val ;
4485+ var cmds = [ '!' , '!!' , '#' , '&' , '*' , '<' , '=' , '>' , '@' , '@@' , '~' , 'regtest1' , 'RT2' ] ;
4486+ cmds . forEach ( function ( name ) {
4487+ CodeMirror . Vim . defineEx ( name , '' , function ( cm , params ) {
4488+ ran = params . commandName ;
4489+ val = params . argString ;
4490+ } ) ;
4491+ helpers . doEx ( ':' + name ) ;
4492+ eq ( ran , name , 'Running ex-command failed' ) ;
4493+ helpers . doEx ( ':' + name + ' x' ) ;
4494+ eq ( val , ' x' , 'Running ex-command with param failed: ' + name ) ;
4495+ if ( / ^ \W + $ / . test ( name ) ) {
4496+ helpers . doEx ( ':' + name + 'y' ) ;
4497+ eq ( val , 'y' , 'Running ex-command with param failed: ' + name ) ;
4498+ }
4499+ else {
4500+ helpers . doEx ( ':' + name + '-y' ) ;
4501+ eq ( val , '-y' , 'Running ex-command with param failed: ' + name ) ;
4502+ }
4503+ if ( name !== '!' ) {
4504+ helpers . doEx ( ':' + name + '!' ) ;
4505+ eq ( ran , name , 'Running ex-command with bang failed' ) ;
4506+ eq ( val , '!' , 'Running ex-command with bang failed: ' + name ) ;
4507+ helpers . doEx ( ':' + name + '!z' ) ;
4508+ eq ( ran , name , 'Running ex-command with bang & param failed' ) ;
4509+ eq ( val , '!z' , 'Running ex-command with bang & param failed: ' + name ) ;
4510+ }
4511+ } ) ;
4512+ } ) ;
44824513// For now, this test needs to be last because it messes up : for future tests.
44834514testVim ( 'ex_map_key2key_from_colon' , function ( cm , vim , helpers ) {
44844515 helpers . doEx ( 'map : x' ) ;
0 commit comments