summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBakudankun <bakudankun@gmail.com>2021-12-11 12:28:08 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-11 12:28:08 +0000
commit29f3a4591528130fded3fe1d63d74bcf22ab4f6c (patch)
treefced5b9da43f96ace4ff4ed360fad2b4046105ac /src/ex_docmd.c
parent205f29c3e9b895dbaa4f738046da455a93c3812a (diff)
patch 8.2.3780: ":cd" works differently on MS-Windowsv8.2.3780
Problem: ":cd" works differently on MS-Windows. Solution: Add the 'cdhome' option. (closes #9324)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 4d739f9a4a..640260a630 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7402,9 +7402,13 @@ changedir_func(
else
prev_dir = pdir;
+ // For UNIX ":cd" means: go to home directory.
+ // On other systems too if 'cdhome' is set.
#if defined(UNIX) || defined(VMS)
- // for UNIX ":cd" means: go to home directory
if (*new_dir == NUL)
+#else
+ if (*new_dir == NUL && p_cdh)
+#endif
{
// use NameBuff for home directory name
# ifdef VMS
@@ -7420,7 +7424,6 @@ changedir_func(
# endif
new_dir = NameBuff;
}
-#endif
dir_differs = new_dir == NULL || pdir == NULL
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
if (new_dir == NULL || (dir_differs && vim_chdir(new_dir)))
@@ -7459,8 +7462,8 @@ ex_cd(exarg_T *eap)
new_dir = eap->arg;
#if !defined(UNIX) && !defined(VMS)
- // for non-UNIX ":cd" means: print current directory
- if (*new_dir == NUL)
+ // for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
+ if (*new_dir == NUL && !p_cdh)
ex_pwd(NULL);
else
#endif