aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/buffer_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-16 20:57:01 +0800
committerGitHub <noreply@github.com>2024-04-16 20:57:01 +0800
commit5cfdaaaeac0f53a621696d8eb6b5a3ba90438c98 (patch)
tree8d058733804bed0990c1a8e6836663f7b2460d5d /test/functional/api/buffer_spec.lua
parent2fc2343728831d890a043def5d9d714947737cf6 (diff)
downloadrneovim-5cfdaaaeac0f53a621696d8eb6b5a3ba90438c98.tar.gz
rneovim-5cfdaaaeac0f53a621696d8eb6b5a3ba90438c98.tar.bz2
rneovim-5cfdaaaeac0f53a621696d8eb6b5a3ba90438c98.zip
fix(api): ignore 'autochdir' when renaming other buf (#28376)
Problem: Renaming non-current buffer changes working directory when 'autochdir' is set. Solution: Temporarily disable 'autochdir'. Add more tests for the win_set_buf change.
Diffstat (limited to 'test/functional/api/buffer_spec.lua')
-rw-r--r--test/functional/api/buffer_spec.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index ec5c046878..12b2c43158 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -2048,6 +2048,37 @@ describe('api/buf', function()
eq(1, fn.filereadable(new_name))
os.remove(new_name)
end)
+
+ describe("with 'autochdir'", function()
+ local topdir
+ local oldbuf
+ local newbuf
+
+ before_each(function()
+ command('set shellslash')
+ topdir = fn.getcwd()
+ t.mkdir(topdir .. '/Xacd')
+
+ oldbuf = api.nvim_get_current_buf()
+ command('vnew')
+ newbuf = api.nvim_get_current_buf()
+ command('set autochdir')
+ end)
+
+ after_each(function()
+ t.rmdir(topdir .. '/Xacd')
+ end)
+
+ it('does not change cwd with non-current buffer', function()
+ api.nvim_buf_set_name(oldbuf, topdir .. '/Xacd/foo.txt')
+ eq(topdir, fn.getcwd())
+ end)
+
+ it('changes cwd with current buffer', function()
+ api.nvim_buf_set_name(newbuf, topdir .. '/Xacd/foo.txt')
+ eq(topdir .. '/Xacd', fn.getcwd())
+ end)
+ end)
end)
describe('nvim_buf_is_loaded', function()