]> granicus.if.org Git - vim/commitdiff
patch 8.0.1231: expanding file name drops dash v8.0.1231
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Oct 2017 15:53:04 +0000 (17:53 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Oct 2017 15:53:04 +0000 (17:53 +0200)
Problem:    Expanding file name drops dash. (stucki)
Solution:   Use the right position. (Christian Brabandt, closes #2184)

src/ex_docmd.c
src/testdir/test_cmdline.vim
src/version.c

index 036569f76c31731e9477590602d223ef5beaadb9..547d1acdbda4ba00148ec23cc0a2190398818eaa 100644 (file)
@@ -10715,9 +10715,12 @@ eval_vars(
                if (*s == '<')          /* "#<99" uses v:oldfiles */
                    ++s;
                i = (int)getdigits(&s);
+               if (s == src + 2 && src[1] == '-')
+                   /* just a minus sign, don't skip over it */
+                   s--;
                *usedlen = (int)(s - src); /* length of what we expand */
 
-               if (src[1] == '<')
+               if (src[1] == '<' && i != 0)
                {
                    if (*usedlen < 2)
                    {
@@ -10740,6 +10743,8 @@ eval_vars(
                }
                else
                {
+                   if (i == 0 && src[1] == '<' && *usedlen > 1)
+                       *usedlen = 1;
                    buf = buflist_findnr(i);
                    if (buf == NULL)
                    {
index ff190821cd4c106605bc8b12af024d8276c1e516..832413e813f957f91f4358e062995571faac0722 100644 (file)
@@ -365,6 +365,27 @@ func Test_cmdline_complete_user_cmd()
   delcommand Foo
 endfunc
 
+func Test_cmdline_write_alternatefile()
+  new
+  call setline('.', ['one', 'two'])
+  f foo.txt
+  new
+  f #-A
+  call assert_equal('foo.txt-A', expand('%'))
+  f #<-B.txt
+  call assert_equal('foo-B.txt', expand('%'))
+  f %<
+  call assert_equal('foo-B', expand('%'))
+  new
+  call assert_fails('f #<', 'E95')
+  bw!
+  f foo-B.txt
+  f %<-A
+  call assert_equal('foo-B-A', expand('%'))
+  bw!
+  bw!
+endfunc
+
 " using a leading backslash here
 set cpo+=C
 
index 221c7576a15fea31831ab694434c1b8e4de8d091..4ce6fee6855b5d2e70330cd48a7166f8fa9e8392 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1231,
 /**/
     1230,
 /**/