mirror of
https://github.com/neovim/neovim.git
synced 2026-05-03 04:25:03 +00:00
getcwd(): Return empty string if CWD is invalid. #5292
Closes #5291 Restores behaviour identical to Vim. If the user calls the VimScript function 'getcwd()' and the working directory cannot be found (for example because the directory has been deleted since the last time it was used) an empty string needs to be returned instead of throwing an error.
This commit is contained in:
@@ -269,3 +269,23 @@ for _, cmd in ipairs {'getcwd', 'haslocaldir'} do
|
||||
end)
|
||||
end
|
||||
|
||||
describe("getcwd()", function ()
|
||||
local temp_dir = "Xtest-functional-ex_cmds-cd_spec.temp"
|
||||
before_each(function()
|
||||
clear()
|
||||
lfs.mkdir(temp_dir)
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
helpers.rmdir(temp_dir)
|
||||
end)
|
||||
|
||||
it("returns empty string if working directory does not exist", function()
|
||||
execute("cd " .. temp_dir)
|
||||
helpers.wait()
|
||||
helpers.rmdir(temp_dir)
|
||||
eq("", helpers.eval("getcwd()"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user