mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.0876: :pwd does not give a hint about the scope of the directory
Problem: :pwd does not give a hint about the scope of the directory
Solution: Make ":verbose pwd" show the scope. (Takuya Fujiwara, closes vim/vim#5469)
950587242c
This commit is contained in:
parent
b1dd90c760
commit
34cfe74568
@ -1304,6 +1304,21 @@ exist, the next-higher scope in the hierarchy applies.
|
||||
*:pw* *:pwd* *E187*
|
||||
:pw[d] Print the current directory name.
|
||||
Also see |getcwd()|.
|
||||
*:pwd-verbose*
|
||||
When 'verbose' is non-zero, |:pwd| will also display
|
||||
what scope the current directory was set. Example: >
|
||||
|
||||
" Set by :cd
|
||||
:verbose pwd
|
||||
[global] /path/to/current
|
||||
|
||||
" Set by :lcd
|
||||
:verbose pwd
|
||||
[window] /path/to/current
|
||||
|
||||
" Set by :tcd
|
||||
:verbose pwd
|
||||
[tabpage] /path/to/current
|
||||
|
||||
So long as no |:lcd| or |:tcd| command has been used, all windows share the
|
||||
same current directory. Using a command to jump to another window doesn't
|
||||
|
@ -1073,6 +1073,8 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (argvars[0].v_type != VAR_STRING) {
|
||||
// Returning an empty string means it failed.
|
||||
// No error message, for historic reasons.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7845,7 +7845,17 @@ static void ex_pwd(exarg_T *eap)
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
slash_adjust(NameBuff);
|
||||
#endif
|
||||
if (p_verbose > 0) {
|
||||
char *context = "global";
|
||||
if (curwin->w_localdir != NULL) {
|
||||
context = "window";
|
||||
} else if (curtab->tp_localdir != NULL) {
|
||||
context = "tabpage";
|
||||
}
|
||||
smsg("[%s] %s", context, (char *)NameBuff);
|
||||
} else {
|
||||
msg(NameBuff);
|
||||
}
|
||||
} else {
|
||||
EMSG(_("E187: Unknown"));
|
||||
}
|
||||
|
@ -84,16 +84,19 @@ func Test_chdir_func()
|
||||
lcd z
|
||||
|
||||
tabfirst
|
||||
call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd')))
|
||||
call chdir('..')
|
||||
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
|
||||
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
|
||||
tabnext | wincmd t
|
||||
call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
|
||||
call chdir('..')
|
||||
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
|
||||
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
|
||||
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
|
||||
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
|
||||
3wincmd w
|
||||
call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
|
||||
call chdir('..')
|
||||
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
|
||||
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
|
||||
|
Loading…
Reference in New Issue
Block a user