]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2303: Vim9: backtick expansion doesn't work for :foldopen v8.2.2303
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Jan 2021 18:23:28 +0000 (19:23 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Jan 2021 18:23:28 +0000 (19:23 +0100)
Problem:    Vim9: backtick expansion doesn't work for :foldopen.
Solution:   Do recognize backtick expansion. (closes #7621)

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

index c9e83d9bca65a7e830544cad8d4a630b82f25384..5b84feceeac2bb57ff6ee54e844dcd6c4bb97979 100644 (file)
@@ -81,6 +81,23 @@ def Test_global_backtick_expansion()
   bwipe!
 enddef
 
+def Test_folddo_backtick_expansion()
+  new
+  var name = 'xxx'
+  folddoopen edit `=name`
+  assert_equal('xxx', bufname())
+  bwipe!
+
+  new
+  setline(1, ['one', 'two'])
+  set nomodified
+  :1,2fold
+  foldclose
+  folddoclose edit `=name`
+  assert_equal('xxx', bufname())
+  bwipe!
+enddef
+
 def Test_hardcopy_wildcards()
   CheckUnix
   CheckFeature postscript
index e7c3ee0a0d044963fb807d6fefdb350ef8b55074..a2553fcc4a52134c326330182cfb2b80d4b32b4d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2303,
 /**/
     2302,
 /**/
index cf5cff85982837ca493ab11329b35f6b09628040..67307f8a938ec359c26de7fdd3d9ae7365364c27 100644 (file)
@@ -7505,6 +7505,13 @@ compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
        }
     }
 
+    if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
+    {
+       // TODO: should only expand when appropriate for the command
+       eap->arg = skiptowhite(eap->arg);
+       has_expr = TRUE;
+    }
+
     if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
     {
        int     count = 0;