aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c1
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/testdir/test_autochdir.vim30
-rw-r--r--src/nvim/window.c2
5 files changed, 39 insertions, 1 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 88938d5099..89e237a517 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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);
}
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index e622a2a68f..ae868bd1cf 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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";
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index e2d3378402..8a273e37f6 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -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);
diff --git a/src/nvim/testdir/test_autochdir.vim b/src/nvim/testdir/test_autochdir.vim
index 0b76828dd7..e172d0cb9a 100644
--- a/src/nvim/testdir/test_autochdir.vim
+++ b/src/nvim/testdir/test_autochdir.vim
@@ -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
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9f6481f5de..c6e32827e7 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -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);
}
}