]> granicus.if.org Git - vim/commitdiff
patch 8.2.3733: Vim9: using "legacy" before range does not work v8.2.3733
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Dec 2021 11:57:00 +0000 (11:57 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Dec 2021 11:57:00 +0000 (11:57 +0000)
Problem:    Vim9: using "legacy" before range does not work.
Solution:   Skip over range before parsing command. (closes #9270)

src/testdir/test_vim9_cmd.vim
src/usercmd.c
src/version.c
src/vim9compile.c

index 22b1896a1df5e371492801c5aa709ca195b71efc..ffb2bb8138295496cc94cb8976c7bd190790a360 100644 (file)
@@ -1019,6 +1019,11 @@ def Test_range_after_command_modifier()
   CheckScriptSuccess(['vim9script', 'silent keepjump :1d _'])
   assert_equal('', getline(1))
   bwipe!
+
+  var lines =<< trim END
+      legacy /pat/
+  END
+  CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat')
 enddef
 
 def Test_silent_pattern()
index 332f995364520acc128841f6a9bbab8c9fb905af..16fbb0db368068b67911b92fab4b56b4a5cf061a 100644 (file)
@@ -1394,6 +1394,7 @@ produce_cmdmods(char_u *buf, cmdmod_T *cmod, int quote)
 #ifdef HAVE_SANDBOX
        {CMOD_SANDBOX, "sandbox"},
 #endif
+       {CMOD_LEGACY, "legacy"},
        {0, NULL}
     };
 
index 6fb7e78be2d73a31ee0c9e7be4e8f36afa4da01c..cdc01a3a7d91ce77332d18547597529a0d790241 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3733,
 /**/
     3732,
 /**/
index 70cf0b4e99503e274d9dc1db3d00f18a98a4dc12..52e5ac8cc3c1196c1306027740fbf9060c65d1b8 100644 (file)
@@ -9903,15 +9903,15 @@ compile_def_function(
         * in "$ENV->func()" the "$" is not a range
         */
        cmd = ea.cmd;
-       if (!(local_cmdmod.cmod_flags & CMOD_LEGACY)
-               && (*cmd != '$' || starts_with_colon)
+       if ((*cmd != '$' || starts_with_colon)
                && (starts_with_colon || !(*cmd == '\''
                       || (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
        {
            ea.cmd = skip_range(ea.cmd, TRUE, NULL);
            if (ea.cmd > cmd)
            {
-               if (!starts_with_colon)
+               if (!starts_with_colon
+                                  && !(local_cmdmod.cmod_flags & CMOD_LEGACY))
                {
                    semsg(_(e_colon_required_before_range_str), cmd);
                    goto erret;
@@ -9920,11 +9920,8 @@ compile_def_function(
                if (ends_excmd2(line, ea.cmd))
                {
                    // A range without a command: jump to the line.
-                   line = skipwhite(line);
-                   while (*line == ':')
-                       ++line;
                    generate_EXEC(&cctx, ISN_EXECRANGE,
-                                           vim_strnsave(line, ea.cmd - line));
+                                             vim_strnsave(cmd, ea.cmd - cmd));
                    line = ea.cmd;
                    goto nextline;
                }