mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
vim-patch:8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Problem: ":verbose pwd" does not mention 'autochdir' was applied.
Solution: Remember the last chdir was done by 'autochdir'. (issue vim/vim#9142)
0526815c15
This commit is contained in:
@@ -1588,6 +1588,7 @@ void do_autochdir(void)
|
||||
&& curbuf->b_ffname != NULL
|
||||
&& vim_chdirfile(curbuf->b_ffname, kCdCauseAuto) == OK) {
|
||||
post_chdir(kCdScopeGlobal, false);
|
||||
last_chdir_reason = "autochdir";
|
||||
shorten_fnames(true);
|
||||
}
|
||||
}
|
||||
|
@@ -7753,6 +7753,7 @@ void post_chdir(CdScope scope, bool trigger_dirchanged)
|
||||
abort();
|
||||
}
|
||||
|
||||
last_chdir_reason = NULL;
|
||||
shorten_fnames(true);
|
||||
|
||||
if (trigger_dirchanged) {
|
||||
@@ -7870,7 +7871,9 @@ static void ex_pwd(exarg_T *eap)
|
||||
#endif
|
||||
if (p_verbose > 0) {
|
||||
char *context = "global";
|
||||
if (curwin->w_localdir != NULL) {
|
||||
if (last_chdir_reason != NULL) {
|
||||
context = last_chdir_reason;
|
||||
} else if (curwin->w_localdir != NULL) {
|
||||
context = "window";
|
||||
} else if (curtab->tp_localdir != NULL) {
|
||||
context = "tabpage";
|
||||
|
@@ -789,6 +789,8 @@ extern char_u *compiled_sys;
|
||||
// directory is not a local directory, globaldir is NULL.
|
||||
EXTERN char_u *globaldir INIT(= NULL);
|
||||
|
||||
EXTERN char *last_chdir_reason INIT(= NULL);
|
||||
|
||||
// Whether 'keymodel' contains "stopsel" and "startsel".
|
||||
EXTERN bool km_stopsel INIT(= false);
|
||||
EXTERN bool km_startsel INIT(= false);
|
||||
|
@@ -26,4 +26,34 @@ func Test_set_filename()
|
||||
call delete('samples/Xtest')
|
||||
endfunc
|
||||
|
||||
func Test_verbose_pwd()
|
||||
CheckFunction test_autochdir
|
||||
let cwd = getcwd()
|
||||
call test_autochdir()
|
||||
|
||||
edit global.txt
|
||||
call assert_match('\[global\].*testdir$', execute('verbose pwd'))
|
||||
|
||||
call mkdir('Xautodir')
|
||||
split Xautodir/local.txt
|
||||
lcd Xautodir
|
||||
call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
|
||||
|
||||
set acd
|
||||
wincmd w
|
||||
call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
|
||||
wincmd w
|
||||
call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
|
||||
set noacd
|
||||
call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
|
||||
wincmd w
|
||||
call assert_match('\[global\].*testdir', execute('verbose pwd'))
|
||||
wincmd w
|
||||
call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
|
||||
|
||||
bwipe!
|
||||
call chdir(cwd)
|
||||
call delete('Xautodir', 'rf')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -4592,6 +4592,7 @@ void fix_current_dir(void)
|
||||
do_autocmd_dirchanged(new_dir, curwin->w_localdir
|
||||
? kCdScopeWindow : kCdScopeTabpage, kCdCauseWindow);
|
||||
}
|
||||
last_chdir_reason = NULL;
|
||||
shorten_fnames(true);
|
||||
}
|
||||
} else if (globaldir != NULL) {
|
||||
@@ -4603,6 +4604,7 @@ void fix_current_dir(void)
|
||||
}
|
||||
}
|
||||
XFREE_CLEAR(globaldir);
|
||||
last_chdir_reason = NULL;
|
||||
shorten_fnames(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user