blob: f6cc1483262e033304b2bab491c7a8d866e13a4b [file] [log] [blame]
Bram Moolenaar5c719942016-07-09 23:40:45 +02001" Test 'autochdir' behavior
2
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02003source check.vim
4CheckOption autochdir
Bram Moolenaar5c719942016-07-09 23:40:45 +02005
6func Test_set_filename()
Bram Moolenaarcf1ba352017-10-27 00:55:04 +02007 let cwd = getcwd()
Bram Moolenaar5c719942016-07-09 23:40:45 +02008 call test_autochdir()
9 set acd
Bram Moolenaar2caad3f2018-12-16 15:38:02 +010010
11 let s:li = []
12 autocmd DirChanged auto call add(s:li, "autocd")
13 autocmd DirChanged auto call add(s:li, expand("<afile>"))
14
Bram Moolenaar5c719942016-07-09 23:40:45 +020015 new
16 w samples/Xtest
17 call assert_equal("Xtest", expand('%'))
18 call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
Bram Moolenaar2caad3f2018-12-16 15:38:02 +010019 call assert_equal(["autocd", getcwd()], s:li)
20
Bram Moolenaar5c719942016-07-09 23:40:45 +020021 bwipe!
Bram Moolenaar2caad3f2018-12-16 15:38:02 +010022 au! DirChanged
Bram Moolenaar5c719942016-07-09 23:40:45 +020023 set noacd
Bram Moolenaar3503d7c2019-11-09 20:10:17 +010024 call chdir(cwd)
Bram Moolenaar5c719942016-07-09 23:40:45 +020025 call delete('samples/Xtest')
26endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020027
Bram Moolenaar05268152021-11-18 18:53:45 +000028func Test_verbose_pwd()
29 let cwd = getcwd()
30 call test_autochdir()
31
32 edit global.txt
33 call assert_match('\[global\].*testdir$', execute('verbose pwd'))
34
35 call mkdir('Xautodir')
36 split Xautodir/local.txt
37 lcd Xautodir
38 call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
39
40 set acd
41 wincmd w
42 call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
zeertzjq64be6aa2021-11-19 11:59:08 +000043 execute 'lcd' cwd
44 call assert_match('\[window\].*testdir$', execute('verbose pwd'))
45 execute 'tcd' cwd
46 call assert_match('\[tabpage\].*testdir$', execute('verbose pwd'))
47 execute 'cd' cwd
48 call assert_match('\[global\].*testdir$', execute('verbose pwd'))
49 edit
50 call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
Bram Moolenaar05268152021-11-18 18:53:45 +000051 wincmd w
52 call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
53 set noacd
54 call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
55 wincmd w
56 call assert_match('\[global\].*testdir', execute('verbose pwd'))
57 wincmd w
58 call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
59
60 bwipe!
61 call chdir(cwd)
62 call delete('Xautodir', 'rf')
63endfunc
64
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020065" vim: shiftwidth=2 sts=2 expandtab