mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Problem: getcwd() is unclear about how 'autochdir' is used. Solution: Update the help for getcwd(). Without any arguments always return the actual current directory. (closes #9142)
This commit is contained in:
@@ -5757,7 +5757,7 @@ getcursorcharpos([{winid}])
|
|||||||
< *getcwd()*
|
< *getcwd()*
|
||||||
getcwd([{winnr} [, {tabnr}]])
|
getcwd([{winnr} [, {tabnr}]])
|
||||||
The result is a String, which is the name of the current
|
The result is a String, which is the name of the current
|
||||||
working directory.
|
working directory. 'autochdir' is ignored.
|
||||||
|
|
||||||
With {winnr} return the local current directory of this window
|
With {winnr} return the local current directory of this window
|
||||||
in the current tab page. {winnr} can be the window number or
|
in the current tab page. {winnr} can be the window number or
|
||||||
@@ -5770,8 +5770,8 @@ getcwd([{winnr} [, {tabnr}]])
|
|||||||
the working directory of the tabpage.
|
the working directory of the tabpage.
|
||||||
If {winnr} is zero use the current window, if {tabnr} is zero
|
If {winnr} is zero use the current window, if {tabnr} is zero
|
||||||
use the current tabpage.
|
use the current tabpage.
|
||||||
Without any arguments, return the working directory of the
|
Without any arguments, return the actual working directory of
|
||||||
current window.
|
the current window.
|
||||||
Return an empty string if the arguments are invalid.
|
Return an empty string if the arguments are invalid.
|
||||||
|
|
||||||
Examples: >
|
Examples: >
|
||||||
|
@@ -1102,13 +1102,15 @@ f_getcwd(typval_T *argvars, typval_T *rettv)
|
|||||||
else
|
else
|
||||||
wp = find_tabwin(&argvars[0], &argvars[1], &tp);
|
wp = find_tabwin(&argvars[0], &argvars[1], &tp);
|
||||||
|
|
||||||
if (wp != NULL && wp->w_localdir != NULL)
|
if (wp != NULL && wp->w_localdir != NULL
|
||||||
|
&& argvars[0].v_type != VAR_UNKNOWN)
|
||||||
rettv->vval.v_string = vim_strsave(wp->w_localdir);
|
rettv->vval.v_string = vim_strsave(wp->w_localdir);
|
||||||
else if (tp != NULL && tp->tp_localdir != NULL)
|
else if (tp != NULL && tp->tp_localdir != NULL
|
||||||
|
&& argvars[0].v_type != VAR_UNKNOWN)
|
||||||
rettv->vval.v_string = vim_strsave(tp->tp_localdir);
|
rettv->vval.v_string = vim_strsave(tp->tp_localdir);
|
||||||
else if (wp != NULL || tp != NULL || global)
|
else if (wp != NULL || tp != NULL || global)
|
||||||
{
|
{
|
||||||
if (globaldir != NULL)
|
if (globaldir != NULL && argvars[0].v_type != VAR_UNKNOWN)
|
||||||
rettv->vval.v_string = vim_strsave(globaldir);
|
rettv->vval.v_string = vim_strsave(globaldir);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -225,4 +225,23 @@ func Test_cd_unknown_dir()
|
|||||||
call delete('Xa', 'rf')
|
call delete('Xa', 'rf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_getcwd_actual_dir()
|
||||||
|
let startdir = getcwd()
|
||||||
|
call mkdir('Xactual')
|
||||||
|
call test_autochdir()
|
||||||
|
set autochdir
|
||||||
|
edit Xactual/file.txt
|
||||||
|
call assert_match('testdir.Xactual$', getcwd())
|
||||||
|
lcd ..
|
||||||
|
call assert_match('testdir$', getcwd())
|
||||||
|
edit
|
||||||
|
call assert_match('testdir.Xactual$', getcwd())
|
||||||
|
call assert_match('testdir$', getcwd(win_getid()))
|
||||||
|
|
||||||
|
set noautochdir
|
||||||
|
bwipe!
|
||||||
|
call chdir(startdir)
|
||||||
|
call delete('Xactual', 'rf')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3618,
|
||||||
/**/
|
/**/
|
||||||
3617,
|
3617,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user