]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0942: expanding to local dir after homedir keeps "~/" v8.2.0942
authorBram Moolenaar <Bram@vim.org>
Wed, 10 Jun 2020 11:12:28 +0000 (13:12 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 Jun 2020 11:12:28 +0000 (13:12 +0200)
Problem:    Expanding to local dir after homedir keeps "~/".
Solution:   Adjust modify_fname(). (Christian Brabandt, closes #6205,
            closes #5979)

src/filepath.c
src/testdir/test_fnamemodify.vim
src/version.c

index 8bc941d3542bf474716c3b67cde449f7e2e0af0e..4a4948ad6e9c687f1f50845853408b2bd52bff67 100644 (file)
@@ -416,7 +416,7 @@ repeat:
        // Need full path first (use expand_env() to remove a "~/")
        if (!has_fullname && !has_homerelative)
        {
-           if (c == '.' && **fnamep == '~')
+           if ((c == '.' || c == '~') && **fnamep == '~')
                p = pbuf = expand_env_save(*fnamep);
            else
                p = pbuf = FullName_save(*fnamep, FALSE);
@@ -2397,11 +2397,9 @@ home_replace(
                if (--dstlen > 0)
                    *dst++ = '~';
 
-               /*
-                * If it's just the home directory, add  "/".
-                */
-               if (!vim_ispathsep(src[0]) && --dstlen > 0)
-                   *dst++ = '/';
+               // Do not add directory separator into dst, because dst is
+               // expected to just return the directory name without the
+               // directory separator '/'.
                break;
            }
            if (p == homedir_env)
index b90d232f95b3cddf45e8ac0903a0667c020c9126..f8ce0b14ac9f059ee62d959068b1393b31b9f0d0 100644 (file)
@@ -31,6 +31,9 @@ func Test_fnamemodify()
   call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
 
   let cwd = getcwd()
+  call chdir($HOME)
+  call assert_equal('foobar', fnamemodify('~/foobar', ':~:.'))
+  call chdir(cwd)
   call mkdir($HOME . '/XXXXXXXX/a', 'p')
   call mkdir($HOME . '/XXXXXXXX/b', 'p')
   call chdir($HOME . '/XXXXXXXX/a/')
index 4c8822a115edbd70cf5412f98bb6723bc2505c7d..570ea1046e1d7c7e03d0f1def2f3bdd4d9220143 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    942,
 /**/
     941,
 /**/