0
0
mirror of https://github.com/vim/vim.git synced 2025-10-26 09:14:23 -04:00

patch 9.1.1605: cannot specify scope for chdir()

Problem:  Cannot specify scope for chdir()
Solution: Add optional scope argument (kuuote)

closes: #17888

Signed-off-by: kuuote <znmxodq1@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
kuuote
2025-08-08 13:09:25 +02:00
committed by Christian Brabandt
parent d82c918e2f
commit 8a65a49d50
7 changed files with 50 additions and 13 deletions

View File

@@ -842,7 +842,22 @@ f_chdir(typval_T *argvars, typval_T *rettv)
vim_free(cwd);
}
if (curwin->w_localdir != NULL)
if (argvars[1].v_type != VAR_UNKNOWN)
{
char_u *s = tv_get_string(&argvars[1]);
if (STRCMP(s, "global") == 0)
scope = CDSCOPE_GLOBAL;
else if (STRCMP(s, "tabpage") == 0)
scope = CDSCOPE_TABPAGE;
else if (STRCMP(s, "window") == 0)
scope = CDSCOPE_WINDOW;
else
{
semsg(_(e_invalid_value_for_argument_str_str), "scope", s);
return;
}
}
else if (curwin->w_localdir != NULL)
scope = CDSCOPE_WINDOW;
else if (curtab->tp_localdir != NULL)
scope = CDSCOPE_TABPAGE;