blob: 46b111d67c7ed40448e61be0fa43203a572d3774 [file] [log] [blame]
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +02001Tests for find completion.
2
3STARTTEST
Bram Moolenaardb41fa22010-08-08 13:07:57 +02004:so small.vim
Bram Moolenaar84f888a2010-08-05 21:40:16 +02005:" Do all test in a separate window to avoid E211 when we recursively
6:" delete the Xfind directory during cleanup
7:"
8:" This will cause a few errors, do it silently.
9:set visualbell
10:"
11:function! DeleteDirectory(dir)
12: if has("win16") || has("win32") || has("win64")
13: exec "silent !rmdir /Q /S " . a:dir
14: else
15: exec "silent !rm -rf " . a:dir
16: endif
17:endfun
18:" On windows a stale "Xfind" directory may exist, remove it so that
19:" we start from a clean state.
20:call DeleteDirectory("Xfind")
21:set nocp
22:new
23:let cwd=getcwd()
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020024:!mkdir Xfind
Bram Moolenaar84f888a2010-08-05 21:40:16 +020025:cd Xfind
26:set path=
27:find
28:w! ../test.out
29:close
30:new
31:set path=.
32:find
33:w >>../test.out
34:close
35:new
36:set path=.,,
37:find
38:w >>../test.out
39:close
40:new
41:set path=./**
42:find
43:w >>../test.out
44:close
45:new
46:" We shouldn't find any file at this point, ../test.out must be empty.
47:!mkdir in
48:cd in
49:!mkdir path
50:exec "cd " . cwd
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020051:e Xfind/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020052SHoly Grail:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020053:e Xfind/in/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020054SJimmy Hoffa:w
Bram Moolenaar84f888a2010-08-05 21:40:16 +020055:e Xfind/in/stuff.txt
56SAnother Holy Grail:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020057:e Xfind/in/path/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020058SE.T.:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020059:set path=Xfind/**
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020060:find file
Bram Moolenaar84f888a2010-08-05 21:40:16 +020061:w >> test.out
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020062:find file
63:w >>test.out
64:find file
65:w >>test.out
Bram Moolenaar84f888a2010-08-05 21:40:16 +020066:" Rerun the previous three find completions, using fullpath in 'path'
67:exec "set path=" . cwd . "/Xfind/**"
68:find file
69:w >> test.out
70:find file
71:w >>test.out
72:find file
73:w >>test.out
74:" Same steps again, using relative and fullpath items that point to the same
75:" recursive location.
76:" This is to test that there are no duplicates in the completion list.
77:exec "set path+=Xfind/**"
78:find file
79:w >> test.out
80:find file
81:w >>test.out
82:find file
83:w >>test.out
84:find file
85:" Test find completion for directory of current buffer, which at this point
86:" is Xfind/in/file.txt.
87:set path=.
88:find st
89:w >> test.out
90:" Test find completion for empty path item ",," which is the current directory
91:cd Xfind
92:set path=,,
93:find f
94:w >> ../test.out
95:cd ..
96:q
97:call DeleteDirectory("Xfind")
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020098:qa!
99ENDTEST
100