vim-patch:9.1.1605: cannot specify scope for chdir() (#35239)

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

closes: vim/vim#17888

8a65a49d50

Co-authored-by: kuuote <znmxodq1@gmail.com>
This commit is contained in:
zeertzjq
2025-08-08 21:50:41 +08:00
committed by GitHub
parent 36361d6e4a
commit 798cb0f19a
6 changed files with 79 additions and 33 deletions

View File

@@ -873,15 +873,22 @@ function vim.fn.charcol(expr, winid) end
--- @return integer
function vim.fn.charidx(string, idx, countcc, utf16) end
--- Change the current working directory to {dir}. The scope of
--- the directory change depends on the directory of the current
--- window:
--- - If the current window has a window-local directory
--- (|:lcd|), then changes the window local directory.
--- - Otherwise, if the current tabpage has a local
--- directory (|:tcd|) then changes the tabpage local
--- directory.
--- - Otherwise, changes the global directory.
--- Changes the current working directory to {dir}. The scope of
--- the change is determined as follows:
--- If {scope} is not present, the current working directory is
--- changed to the scope of the current directory:
--- - If the window local directory (|:lcd|) is set, it
--- changes the current working directory for that scope.
--- - Otherwise, if the tab page local directory (|:tcd|) is
--- set, it changes the current directory for that scope.
--- - Otherwise, changes the global directory for that scope.
---
--- If {scope} is present, changes the current working directory
--- for the specified scope:
--- "window" Changes the window local directory. |:lcd|
--- "tabpage" Changes the tab page local directory. |:tcd|
--- "global" Changes the global directory. |:cd|
---
--- {dir} must be a String.
--- If successful, returns the previous working directory. Pass
--- this to another chdir() to restore the directory.
@@ -896,8 +903,9 @@ function vim.fn.charidx(string, idx, countcc, utf16) end
--- <
---
--- @param dir string
--- @param scope? string
--- @return string
function vim.fn.chdir(dir) end
function vim.fn.chdir(dir, scope) end
--- Get the amount of indent for line {lnum} according the
--- |C-indenting| rules, as with 'cindent'.