comparison src/testdir/test_autocmd.vim @ 15184:90ab2d3ce11d v8.1.0602

patch 8.1.0602: DirChanged is also triggered when directory didn't change commit https://github.com/vim/vim/commit/2caad3fbbdbf1486a176c9f6bfbc3d9be90e09f7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 16 15:38:02 2018 +0100 patch 8.1.0602: DirChanged is also triggered when directory didn't change Problem: DirChanged is also triggered when the directory didn't change. (Daniel Hahler) Solution: Compare the current with the new directory. (closes #3697)
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Dec 2018 15:45:06 +0100
parents c71d65c3672f
children 6ab9c18708c4
comparison
equal deleted inserted replaced
15183:c43fefb0ab38 15184:90ab2d3ce11d
1203 augroup test_dirchanged 1203 augroup test_dirchanged
1204 autocmd! 1204 autocmd!
1205 augroup END 1205 augroup END
1206 let s:li = [] 1206 let s:li = []
1207 let s:dir_this = getcwd() 1207 let s:dir_this = getcwd()
1208 let s:dir_other = s:dir_this . '/foo' 1208 let s:dir_foo = s:dir_this . '/foo'
1209 call mkdir(s:dir_other) 1209 call mkdir(s:dir_foo)
1210 let s:dir_bar = s:dir_this . '/bar'
1211 call mkdir(s:dir_bar)
1210 endfunc 1212 endfunc
1211 1213
1212 function s:After_test_dirchanged() 1214 function s:After_test_dirchanged()
1213 exe 'cd' s:dir_this 1215 exe 'cd' s:dir_this
1214 call delete(s:dir_other, 'd') 1216 call delete(s:dir_foo, 'd')
1217 call delete(s:dir_bar, 'd')
1215 augroup test_dirchanged 1218 augroup test_dirchanged
1216 autocmd! 1219 autocmd!
1217 augroup END 1220 augroup END
1218 endfunc 1221 endfunc
1219 1222
1220 function Test_dirchanged_global() 1223 function Test_dirchanged_global()
1221 call s:Before_test_dirchanged() 1224 call s:Before_test_dirchanged()
1222 autocmd test_dirchanged DirChanged global call add(s:li, "cd:") 1225 autocmd test_dirchanged DirChanged global call add(s:li, "cd:")
1223 autocmd test_dirchanged DirChanged global call add(s:li, expand("<afile>")) 1226 autocmd test_dirchanged DirChanged global call add(s:li, expand("<afile>"))
1224 exe 'cd' s:dir_other 1227 exe 'cd' s:dir_foo
1225 call assert_equal(["cd:", s:dir_other], s:li) 1228 call assert_equal(["cd:", s:dir_foo], s:li)
1226 exe 'lcd' s:dir_other 1229 exe 'cd' s:dir_foo
1227 call assert_equal(["cd:", s:dir_other], s:li) 1230 call assert_equal(["cd:", s:dir_foo], s:li)
1231 exe 'lcd' s:dir_bar
1232 call assert_equal(["cd:", s:dir_foo], s:li)
1228 call s:After_test_dirchanged() 1233 call s:After_test_dirchanged()
1229 endfunc 1234 endfunc
1230 1235
1231 function Test_dirchanged_local() 1236 function Test_dirchanged_local()
1232 call s:Before_test_dirchanged() 1237 call s:Before_test_dirchanged()
1233 autocmd test_dirchanged DirChanged window call add(s:li, "lcd:") 1238 autocmd test_dirchanged DirChanged window call add(s:li, "lcd:")
1234 autocmd test_dirchanged DirChanged window call add(s:li, expand("<afile>")) 1239 autocmd test_dirchanged DirChanged window call add(s:li, expand("<afile>"))
1235 exe 'cd' s:dir_other 1240 exe 'cd' s:dir_foo
1236 call assert_equal([], s:li) 1241 call assert_equal([], s:li)
1237 exe 'lcd' s:dir_other 1242 exe 'lcd' s:dir_bar
1238 call assert_equal(["lcd:", s:dir_other], s:li) 1243 call assert_equal(["lcd:", s:dir_bar], s:li)
1244 exe 'lcd' s:dir_bar
1245 call assert_equal(["lcd:", s:dir_bar], s:li)
1239 call s:After_test_dirchanged() 1246 call s:After_test_dirchanged()
1240 endfunc 1247 endfunc
1241 1248
1242 function Test_dirchanged_auto() 1249 function Test_dirchanged_auto()
1243 if !exists('+autochdir') 1250 if !exists('+autochdir')
1248 autocmd test_dirchanged DirChanged auto call add(s:li, "auto:") 1255 autocmd test_dirchanged DirChanged auto call add(s:li, "auto:")
1249 autocmd test_dirchanged DirChanged auto call add(s:li, expand("<afile>")) 1256 autocmd test_dirchanged DirChanged auto call add(s:li, expand("<afile>"))
1250 set acd 1257 set acd
1251 exe 'cd ..' 1258 exe 'cd ..'
1252 call assert_equal([], s:li) 1259 call assert_equal([], s:li)
1253 exe 'edit ' . s:dir_other . '/Xfile' 1260 exe 'edit ' . s:dir_foo . '/Xfile'
1254 call assert_equal(s:dir_other, getcwd()) 1261 call assert_equal(s:dir_foo, getcwd())
1255 call assert_equal(["auto:", s:dir_other], s:li) 1262 call assert_equal(["auto:", s:dir_foo], s:li)
1256 set noacd 1263 set noacd
1257 bwipe! 1264 bwipe!
1258 call s:After_test_dirchanged() 1265 call s:After_test_dirchanged()
1259 endfunc 1266 endfunc
1260 1267