Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 13170:6559e98f3e74 v8.0.1459
patch 8.0.1459: cannot handle change of directory
commit https://github.com/vim/vim/commit/b7407d3fc9496f9048fb65ab17b5ba3444965c0e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 3 17:36:27 2018 +0100
patch 8.0.1459: cannot handle change of directory
Problem: Cannot handle change of directory.
Solution: Add the DirChanged autocommand event. (Andy Massimino,
closes #888) Avoid changing directory for 'autochdir' too often.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 03 Feb 2018 17:45:05 +0100 |
parents | 59a16624400a |
children | f83d3a633ccb |
comparison
equal
deleted
inserted
replaced
13169:570e10c8313d | 13170:6559e98f3e74 |
---|---|
1188 " Nasty autocommand: wipe buffer on any event. | 1188 " Nasty autocommand: wipe buffer on any event. |
1189 au * x bwipe | 1189 au * x bwipe |
1190 call assert_fails('lv½ /x', 'E480') | 1190 call assert_fails('lv½ /x', 'E480') |
1191 au! | 1191 au! |
1192 endfunc | 1192 endfunc |
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 |