Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 34799:f9b510d3ed32 v9.1.0272
patch 9.1.0272: autocmd may change cwd after :tcd and :lcd
Commit: https://github.com/vim/vim/commit/9d956ee8eab64a0d412b045305fde5bc03d95d4a
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun Apr 7 18:16:10 2024 +0200
patch 9.1.0272: autocmd may change cwd after :tcd and :lcd
Problem: Autocommand may change currect directory after :tcd and :lcd.
Solution: Also clear tp_localdir and w_localdir when using aucmd_win.
(zeertzjq)
closes: #14435
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 07 Apr 2024 18:30:03 +0200 |
parents | 1104d85c7dcc |
children | f5ebd5ee3d53 |
comparison
equal
deleted
inserted
replaced
34798:83cd18134b6f | 34799:f9b510d3ed32 |
---|---|
3725 call assert_false(bufexists('Xa.txt')) | 3725 call assert_false(bufexists('Xa.txt')) |
3726 bwipe Xb.txt | 3726 bwipe Xb.txt |
3727 call assert_false(bufexists('Xb.txt')) | 3727 call assert_false(bufexists('Xb.txt')) |
3728 endfunc | 3728 endfunc |
3729 | 3729 |
3730 " Test that using the autocommand window doesn't change current directory. | |
3731 func Test_autocmd_window_cwd() | |
3732 let saveddir = getcwd() | |
3733 call mkdir('Xcwd/a/b/c/d', 'pR') | |
3734 | |
3735 new Xa.txt | |
3736 tabnew | |
3737 new Xb.txt | |
3738 | |
3739 tabprev | |
3740 cd Xcwd | |
3741 call assert_match('/Xcwd$', getcwd()) | |
3742 call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd'))) | |
3743 | |
3744 autocmd BufEnter Xb.txt lcd ./a/b/c/d | |
3745 doautoall BufEnter | |
3746 au! BufEnter | |
3747 call assert_match('/Xcwd$', getcwd()) | |
3748 call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd'))) | |
3749 | |
3750 tabnext | |
3751 cd ./a | |
3752 tcd ./b | |
3753 lcd ./c | |
3754 call assert_match('/Xcwd/a/b/c$', getcwd()) | |
3755 call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd'))) | |
3756 | |
3757 autocmd BufEnter Xa.txt call assert_match('Xcwd/a/b/c$', getcwd()) | |
3758 doautoall BufEnter | |
3759 au! BufEnter | |
3760 call assert_match('/Xcwd/a/b/c$', getcwd()) | |
3761 call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd'))) | |
3762 bwipe! | |
3763 call assert_match('/Xcwd/a/b$', getcwd()) | |
3764 call assert_match('\[tabpage\] .*/Xcwd/a/b$', trim(execute('verbose pwd'))) | |
3765 bwipe! | |
3766 call assert_match('/Xcwd/a$', getcwd()) | |
3767 call assert_match('\[global\] .*/Xcwd/a$', trim(execute('verbose pwd'))) | |
3768 bwipe! | |
3769 | |
3770 call chdir(saveddir) | |
3771 endfunc | |
3772 | |
3730 func Test_bufwipeout_changes_window() | 3773 func Test_bufwipeout_changes_window() |
3731 " This should not crash, but we don't have any expectations about what | 3774 " This should not crash, but we don't have any expectations about what |
3732 " happens, changing window in BufWipeout has unpredictable results. | 3775 " happens, changing window in BufWipeout has unpredictable results. |
3733 tabedit | 3776 tabedit |
3734 let g:window_id = win_getid() | 3777 let g:window_id = win_getid() |