diff src/filepath.c @ 20780:300fbeef8c82 v8.2.0942

patch 8.2.0942: expanding to local dir after homedir keeps "~/" Commit: https://github.com/vim/vim/commit/0e390f40e944036fb558a63b91238cfda128d95f Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 10 13:12:28 2020 +0200 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 https://github.com/vim/vim/issues/6205, closes #5979)
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jun 2020 13:15:03 +0200
parents d91b8d1e5198
children 9064044fd4f6
line wrap: on
line diff
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -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)