@@ -1190,3 +1190,59 @@ func Test_nocatch_wipe_dummy_buffer()
11901190 call assert_fails (' lv½ /x' , ' E480' )
11911191 au !
11921192endfunc
1193+
1194+ function s: Before_test_dirchanged ()
1195+ augroup test_dirchanged
1196+ autocmd !
1197+ augroup END
1198+ let s: li = []
1199+ let s: dir_this = getcwd ()
1200+ let s: dir_other = s: dir_this . ' /foo'
1201+ call mkdir (s: dir_other )
1202+ endfunc
1203+
1204+ function s: After_test_dirchanged ()
1205+ exe ' cd' s: dir_this
1206+ call delete (s: dir_other , ' d' )
1207+ augroup test_dirchanged
1208+ autocmd !
1209+ augroup END
1210+ endfunc
1211+
1212+ function Test_dirchanged_global ()
1213+ call s: Before_test_dirchanged ()
1214+ autocmd test_dirchanged DirChanged global call add (s: li , " cd:" )
1215+ autocmd test_dirchanged DirChanged global call add (s: li , expand (" <afile>" ))
1216+ exe ' cd' s: dir_other
1217+ call assert_equal ([" cd:" , s: dir_other ], s: li )
1218+ exe ' lcd' s: dir_other
1219+ call assert_equal ([" cd:" , s: dir_other ], s: li )
1220+ call s: After_test_dirchanged ()
1221+ endfunc
1222+
1223+ function Test_dirchanged_local ()
1224+ call s: Before_test_dirchanged ()
1225+ autocmd test_dirchanged DirChanged window call add (s: li , " lcd:" )
1226+ autocmd test_dirchanged DirChanged window call add (s: li , expand (" <afile>" ))
1227+ exe ' cd' s: dir_other
1228+ call assert_equal ([], s: li )
1229+ exe ' lcd' s: dir_other
1230+ call assert_equal ([" lcd:" , s: dir_other ], s: li )
1231+ call s: After_test_dirchanged ()
1232+ endfunc
1233+
1234+ function Test_dirchanged_auto ()
1235+ call s: Before_test_dirchanged ()
1236+ call test_autochdir ()
1237+ autocmd test_dirchanged DirChanged auto call add (s: li , " auto:" )
1238+ autocmd test_dirchanged DirChanged auto call add (s: li , expand (" <afile>" ))
1239+ set acd
1240+ exe ' cd ..'
1241+ call assert_equal ([], s: li )
1242+ exe ' edit ' . s: dir_other . ' /Xfile'
1243+ call assert_equal (s: dir_other , getcwd ())
1244+ call assert_equal ([" auto:" , s: dir_other ], s: li )
1245+ set noacd
1246+ bwipe!
1247+ call s: After_test_dirchanged ()
1248+ endfunc
0 commit comments