Patch 8.0.1231
Problem:    Expanding file name drops dash. (stucki)
Solution:   Use the right position. (Christian Brabandt, closes #2184)
Files:      src/ex_docmd.c, src/testdir/test_cmdline.vim


*** ../vim-8.0.1230/src/ex_docmd.c      2017-10-24 21:49:32.230837763 +0200
--- src/ex_docmd.c      2017-10-28 17:42:37.452274925 +0200
***************
*** 10715,10723 ****
                if (*s == '<')          /* "#<99" uses v:oldfiles */
                    ++s;
                i = (int)getdigits(&s);
                *usedlen = (int)(s - src); /* length of what we expand */
  
!               if (src[1] == '<')
                {
                    if (*usedlen < 2)
                    {
--- 10715,10726 ----
                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] == '<' && i != 0)
                {
                    if (*usedlen < 2)
                    {
***************
*** 10740,10745 ****
--- 10743,10750 ----
                }
                else
                {
+                   if (i == 0 && src[1] == '<' && *usedlen > 1)
+                       *usedlen = 1;
                    buf = buflist_findnr(i);
                    if (buf == NULL)
                    {
*** ../vim-8.0.1230/src/testdir/test_cmdline.vim        2017-10-15 
22:07:35.207683184 +0200
--- src/testdir/test_cmdline.vim        2017-10-28 17:37:31.986373465 +0200
***************
*** 365,370 ****
--- 365,391 ----
    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
  
*** ../vim-8.0.1230/src/version.c       2017-10-28 16:07:29.191602155 +0200
--- src/version.c       2017-10-28 17:38:01.122173307 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1231,
  /**/

-- 
In Africa some of the native tribes have a custom of beating the ground
with clubs and uttering spine chilling cries.  Anthropologists call
this a form of primitive self-expression.  In America we call it golf.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui