mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
vim-patch:8.2.3933: after ":cd" fails ":cd -" is incorrect
Problem: After ":cd" fails ":cd -" is incorrect. Solution: Set the previous directory only after successfully changing directory. (Richard Doty, closes vim/vim#9419, closes vim/vim#8983)3d0abad5bf
Adjust the test's error message check due to missing patch vim-patch:8.2.3973: tiny build fails Problem: Tiny build fails. Solution: Adjust #ifdefs0f7a5e758c
vim-patch:8.2.3978: build error when using dynamycally loaded Python 3 Problem: Build error when using dynamycally loaded Python 3. Solution: Adjust #ifdef.6b1a99dfe3
vim-patch:8.2.4013: build failure without the spell feature Problem: Build failure without the spell feature. Solution: Adjust #ifdefs.e60b3c47d7
vim-patch:8.2.4032: ATTRIBUTE_NORETURN is not needed Problem: ATTRIBUTE_NORETURN is not needed. Solution: Use NORETURN(). (Ozaki Kiichi, closes vim/vim#9487)e12406526a
vim-patch:8.2.4048: gcc complains about use of "%p" in printf Problem: gcc complains about use of "%p" in printf. Solution: Add (void *) typecast. (Dominique Pellé, closes vim/vim#9494)c14f667626
This commit is contained in:
@@ -7825,7 +7825,6 @@ void post_chdir(CdScope scope, bool trigger_dirchanged)
|
||||
/// @return true if the directory is successfully changed.
|
||||
bool changedir_func(char_u *new_dir, CdScope scope)
|
||||
{
|
||||
char_u *tofree;
|
||||
char_u *pdir = NULL;
|
||||
bool retval = false;
|
||||
|
||||
@@ -7843,26 +7842,12 @@ bool changedir_func(char_u *new_dir, CdScope scope)
|
||||
new_dir = pdir;
|
||||
}
|
||||
|
||||
// Free the previous directory
|
||||
tofree = get_prevdir(scope);
|
||||
|
||||
if (os_dirname(NameBuff, MAXPATHL) == OK) {
|
||||
pdir = vim_strsave(NameBuff);
|
||||
} else {
|
||||
pdir = NULL;
|
||||
}
|
||||
|
||||
switch (scope) {
|
||||
case kCdScopeTabpage:
|
||||
curtab->tp_prevdir = pdir;
|
||||
break;
|
||||
case kCdScopeWindow:
|
||||
curwin->w_prevdir = pdir;
|
||||
break;
|
||||
default:
|
||||
prev_dir = pdir;
|
||||
}
|
||||
|
||||
// For UNIX ":cd" means: go to home directory.
|
||||
// On other systems too if 'cdhome' is set.
|
||||
#if defined(UNIX)
|
||||
@@ -7878,12 +7863,27 @@ bool changedir_func(char_u *new_dir, CdScope scope)
|
||||
bool 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) == 0)) {
|
||||
char_u **pp;
|
||||
|
||||
switch (scope) {
|
||||
case kCdScopeTabpage:
|
||||
pp = &curtab->tp_prevdir;
|
||||
break;
|
||||
case kCdScopeWindow:
|
||||
pp = &curwin->w_prevdir;
|
||||
break;
|
||||
default:
|
||||
pp = &prev_dir;
|
||||
}
|
||||
xfree(*pp);
|
||||
*pp = pdir;
|
||||
|
||||
post_chdir(scope, dir_differs);
|
||||
retval = true;
|
||||
} else {
|
||||
emsg(_(e_failed));
|
||||
xfree(pdir);
|
||||
}
|
||||
xfree(tofree);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@@ -44,6 +44,15 @@ func Test_cd_minus()
|
||||
cd -
|
||||
call assert_equal(path, getcwd())
|
||||
|
||||
" Test for :cd - after a failed :cd
|
||||
" v8.2.1183 is not ported yet
|
||||
" call assert_fails('cd /nonexistent', 'E344:')
|
||||
call assert_fails('cd /nonexistent', 'E472:')
|
||||
call assert_equal(path, getcwd())
|
||||
cd -
|
||||
call assert_equal(path_dotdot, getcwd())
|
||||
cd -
|
||||
|
||||
" Test for :cd - without a previous directory
|
||||
let lines =<< trim [SCRIPT]
|
||||
call assert_fails('cd -', 'E186:')
|
||||
|
Reference in New Issue
Block a user