0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.0942: expanding to local dir after homedir keeps "~/"

Problem:    Expanding to local dir after homedir keeps "~/".
Solution:   Adjust modify_fname(). (Christian Brabandt, closes #6205,
            closes #5979)
This commit is contained in:
Bram Moolenaar 2020-06-10 13:12:28 +02:00
parent 517f00f788
commit 0e390f40e9
3 changed files with 9 additions and 6 deletions

View File

@ -416,7 +416,7 @@ repeat:
// Need full path first (use expand_env() to remove a "~/") // Need full path first (use expand_env() to remove a "~/")
if (!has_fullname && !has_homerelative) if (!has_fullname && !has_homerelative)
{ {
if (c == '.' && **fnamep == '~') if ((c == '.' || c == '~') && **fnamep == '~')
p = pbuf = expand_env_save(*fnamep); p = pbuf = expand_env_save(*fnamep);
else else
p = pbuf = FullName_save(*fnamep, FALSE); p = pbuf = FullName_save(*fnamep, FALSE);
@ -2397,11 +2397,9 @@ home_replace(
if (--dstlen > 0) if (--dstlen > 0)
*dst++ = '~'; *dst++ = '~';
/* // Do not add directory separator into dst, because dst is
* If it's just the home directory, add "/". // expected to just return the directory name without the
*/ // directory separator '/'.
if (!vim_ispathsep(src[0]) && --dstlen > 0)
*dst++ = '/';
break; break;
} }
if (p == homedir_env) if (p == homedir_env)

View File

@ -31,6 +31,9 @@ func Test_fnamemodify()
call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r')) call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
let cwd = getcwd() 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/a', 'p')
call mkdir($HOME . '/XXXXXXXX/b', 'p') call mkdir($HOME . '/XXXXXXXX/b', 'p')
call chdir($HOME . '/XXXXXXXX/a/') call chdir($HOME . '/XXXXXXXX/a/')

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
942,
/**/ /**/
941, 941,
/**/ /**/