vim-patch:8.2.3780: ":cd" works differently on MS-Windows

Problem:    ":cd" works differently on MS-Windows.
Solution:   Add the 'cdhome' option. (closes vim/vim#9324)
29f3a45915
This commit is contained in:
zeertzjq
2021-12-25 11:31:54 +08:00
parent 0d7a97224f
commit 42cf76fd0a
8 changed files with 52 additions and 12 deletions

View File

@@ -7807,14 +7807,17 @@ bool changedir_func(char_u *new_dir, CdScope scope)
prev_dir = pdir;
}
// For UNIX ":cd" means: go to home directory.
// On other systems too if 'cdhome' is set.
#if defined(UNIX)
// On 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.
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
new_dir = NameBuff;
}
#endif
bool dir_differs = new_dir == NULL || pdir == NULL
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
@@ -7834,9 +7837,9 @@ void ex_cd(exarg_T *eap)
{
char_u *new_dir;
new_dir = eap->arg;
#if !defined(UNIX) && !defined(VMS)
// for non-UNIX ":cd" means: print current directory
if (*new_dir == NUL) {
#if !defined(UNIX)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh) {
ex_pwd(NULL);
} else
#endif