diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-08 06:25:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 06:25:22 +0800 |
commit | d188b929d46d74ca6a93e15c39cf06896a53fbf7 (patch) | |
tree | 66c0fb1f7576877c648b16cf0f7e98c734da44f7 /test | |
parent | d32cbef59551a1808caea2ddaeac323fdc18d6b6 (diff) | |
download | rneovim-d188b929d46d74ca6a93e15c39cf06896a53fbf7.tar.gz rneovim-d188b929d46d74ca6a93e15c39cf06896a53fbf7.tar.bz2 rneovim-d188b929d46d74ca6a93e15c39cf06896a53fbf7.zip |
vim-patch:9.1.0272: autocmd may change cwd after :tcd and :lcd (#28223)
Problem: Autocommand may change currect directory after :tcd and :lcd.
Solution: Also clear tp_localdir and w_localdir when using aucmd_win.
(zeertzjq)
closes: vim/vim#14435
https://github.com/vim/vim/commit/9d956ee8eab64a0d412b045305fde5bc03d95d4a
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_autocmd.vim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index c1bbc8a129..7a9799107a 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -3522,6 +3522,49 @@ func Test_switch_window_in_autocmd_window() call assert_false(bufexists('Xb.txt')) endfunc +" Test that using the autocommand window doesn't change current directory. +func Test_autocmd_window_cwd() + let saveddir = getcwd() + call mkdir('Xcwd/a/b/c/d', 'pR') + + new Xa.txt + tabnew + new Xb.txt + + tabprev + cd Xcwd + call assert_match('/Xcwd$', getcwd()) + call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd'))) + + autocmd BufEnter Xb.txt lcd ./a/b/c/d + doautoall BufEnter + au! BufEnter + call assert_match('/Xcwd$', getcwd()) + call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd'))) + + tabnext + cd ./a + tcd ./b + lcd ./c + call assert_match('/Xcwd/a/b/c$', getcwd()) + call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd'))) + + autocmd BufEnter Xa.txt call assert_match('Xcwd/a/b/c$', getcwd()) + doautoall BufEnter + au! BufEnter + call assert_match('/Xcwd/a/b/c$', getcwd()) + call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd'))) + bwipe! + call assert_match('/Xcwd/a/b$', getcwd()) + call assert_match('\[tabpage\] .*/Xcwd/a/b$', trim(execute('verbose pwd'))) + bwipe! + call assert_match('/Xcwd/a$', getcwd()) + call assert_match('\[global\] .*/Xcwd/a$', trim(execute('verbose pwd'))) + bwipe! + + call chdir(saveddir) +endfunc + func Test_bufwipeout_changes_window() " This should not crash, but we don't have any expectations about what " happens, changing window in BufWipeout has unpredictable results. |