summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-09 20:53:59 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-09 20:53:59 +0100
commit5459129af2a832a027a1e7ca2d6177c26647d64f (patch)
treee001cd02a219302d36cb41ede9fe4c72bdbb9718 /src/evalfunc.c
parent0d2073773218736e368786f0db7024bd9b9e7912 (diff)
patch 8.0.1489: there is no easy way to get the global directoryv8.0.1489
Problem: There is no easy way to get the global directory, esp. if some windows have a local directory. Solution: Make getcwd(-1) return the global directory. (Andy Massimino, closes #2606)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index a19f706b25..632b982de0 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4613,16 +4613,21 @@ f_getcwd(typval_T *argvars, typval_T *rettv)
{
win_T *wp = NULL;
char_u *cwd;
+ int global = FALSE;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
- wp = find_tabwin(&argvars[0], &argvars[1]);
- if (wp != NULL)
+ if (argvars[0].v_type == VAR_NUMBER && argvars[0].vval.v_number == -1)
+ global = TRUE;
+ else
+ wp = find_tabwin(&argvars[0], &argvars[1]);
+
+ if (wp != NULL && wp->w_localdir != NULL)
+ rettv->vval.v_string = vim_strsave(wp->w_localdir);
+ else if (wp != NULL || global)
{
- if (wp->w_localdir != NULL)
- rettv->vval.v_string = vim_strsave(wp->w_localdir);
- else if (globaldir != NULL)
+ if (globaldir != NULL)
rettv->vval.v_string = vim_strsave(globaldir);
else
{