Patch 8.2.3618
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)
Files: runtime/doc/eval.txt, src/filepath.c, src/testdir/test_cd.vim
*** ../vim-8.2.3617/runtime/doc/eval.txt 2021-11-16 17:19:24.502463313
+0000
--- runtime/doc/eval.txt 2021-11-18 19:28:16.753944775 +0000
***************
*** 5707,5713 ****
< *getcwd()*
getcwd([{winnr} [, {tabnr}]])
The result is a String, which is the name of the current
! working directory.
With {winnr} return the local current directory of this window
in the current tab page. {winnr} can be the window number or
--- 5757,5763 ----
< *getcwd()*
getcwd([{winnr} [, {tabnr}]])
The result is a String, which is the name of the current
! working directory. 'autochdir' is ignored.
With {winnr} return the local current directory of this window
in the current tab page. {winnr} can be the window number or
***************
*** 5720,5727 ****
the working directory of the tabpage.
If {winnr} is zero use the current window, if {tabnr} is zero
use the current tabpage.
! Without any arguments, return the working directory of the
! current window.
Return an empty string if the arguments are invalid.
Examples: >
--- 5770,5777 ----
the working directory of the tabpage.
If {winnr} is zero use the current window, if {tabnr} is zero
use the current tabpage.
! Without any arguments, return the actual working directory of
! the current window.
Return an empty string if the arguments are invalid.
Examples: >
*** ../vim-8.2.3617/src/filepath.c 2021-07-27 21:00:39.745712396 +0100
--- src/filepath.c 2021-11-18 19:50:57.718251305 +0000
***************
*** 1102,1114 ****
else
wp = find_tabwin(&argvars[0], &argvars[1], &tp);
! if (wp != NULL && wp->w_localdir != NULL)
rettv->vval.v_string = vim_strsave(wp->w_localdir);
! else if (tp != NULL && tp->tp_localdir != NULL)
rettv->vval.v_string = vim_strsave(tp->tp_localdir);
else if (wp != NULL || tp != NULL || global)
{
! if (globaldir != NULL)
rettv->vval.v_string = vim_strsave(globaldir);
else
{
--- 1102,1116 ----
else
wp = find_tabwin(&argvars[0], &argvars[1], &tp);
! if (wp != NULL && wp->w_localdir != NULL
! && argvars[0].v_type != VAR_UNKNOWN)
rettv->vval.v_string = vim_strsave(wp->w_localdir);
! else if (tp != NULL && tp->tp_localdir != NULL
! && argvars[0].v_type != VAR_UNKNOWN)
rettv->vval.v_string = vim_strsave(tp->tp_localdir);
else if (wp != NULL || tp != NULL || global)
{
! if (globaldir != NULL && argvars[0].v_type != VAR_UNKNOWN)
rettv->vval.v_string = vim_strsave(globaldir);
else
{
*** ../vim-8.2.3617/src/testdir/test_cd.vim 2021-10-03 19:29:44.279938580
+0100
--- src/testdir/test_cd.vim 2021-11-18 19:55:33.733120766 +0000
***************
*** 225,228 ****
--- 225,247 ----
call delete('Xa', 'rf')
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-8.2.3617/src/version.c 2021-11-18 18:52:08.828648753 +0000
--- src/version.c 2021-11-18 19:30:27.345779217 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3618,
/**/
--
It's not hard to meet expenses, they're everywhere.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211118204758.18EEA1C6578%40moolenaar.net.