1Tests for find completion.
2
3STARTTEST
4:so small.vim
5:" 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:set nocp viminfo+=nviminfo
11:"
12:function! DeleteDirectory(dir)
13: if has("win16") || has("win32") || has("win64") || has("dos16") || has("dos32")
14:  exec "silent !rmdir /Q /S " . a:dir
15: else
16:  exec "silent !rm -rf " . a:dir
17: endif
18:endfun
19:" On windows a stale "Xfind" directory may exist, remove it so that
20:" we start from a clean state.
21:call DeleteDirectory("Xfind")
22:new
23:let cwd=getcwd()
24:let test_out = cwd . '/test.out'
25:call mkdir('Xfind')
26:cd Xfind
27:set path=
28:find 	
29:exec "w! " . test_out
30:close
31:new
32:set path=.
33:find 	
34:exec "w >>" . test_out
35:close
36:new
37:set path=.,,
38:find 	
39:exec "w >>" . test_out
40:close
41:new
42:set path=./**
43:find 	
44:exec "w >>" . test_out
45:close
46:new
47:" We shouldn't find any file at this point, test.out must be empty.
48:call mkdir('in')
49:cd in
50:call mkdir('path')
51:exec "cd " . cwd
52:e Xfind/file.txt
53SHoly Grail:w
54:e Xfind/in/file.txt
55SJimmy Hoffa:w
56:e Xfind/in/stuff.txt
57SAnother Holy Grail:w
58:e Xfind/in/path/file.txt
59SE.T.:w
60:set path=Xfind/**
61:find file	
62:exec "w >>" . test_out
63:find file		
64:exec "w >>" . test_out
65:find file			
66:exec "w >>" . test_out
67:" Rerun the previous three find completions, using fullpath in 'path'
68:exec "set path=" . cwd . "/Xfind/**"
69:find file	
70:exec "w >>" .  test_out
71:find file		
72:exec "w >>" . test_out
73:find file			
74:exec "w >>" . test_out
75:" Same steps again, using relative and fullpath items that point to the same
76:" recursive location.
77:" This is to test that there are no duplicates in the completion list.
78:exec "set path+=Xfind/**"
79:find file	
80:exec "w >>" .  test_out
81:find file		
82:exec "w >>" . test_out
83:find file			
84:exec "w >>" . test_out
85:find file		
86:" Test find completion for directory of current buffer, which at this point
87:" is Xfind/in/file.txt.
88:set path=.
89:find st	
90:exec "w >>" .  test_out
91:" Test find completion for empty path item ",," which is the current directory
92:cd Xfind
93:set path=,,
94:find f		
95:exec "w >>" . test_out
96:" Test shortening of
97:"
98:"    foo/x/bar/voyager.txt
99:"    foo/y/bar/voyager.txt
100:"
101:" When current directory is above foo/ they should be shortened to (in order
102:" of appearance):
103:"
104:"    x/bar/voyager.txt
105:"    y/bar/voyager.txt
106:call mkdir('foo')
107:cd foo
108:call mkdir('x')
109:call mkdir('y')
110:cd x
111:call mkdir('bar')
112:cd ..
113:cd y
114:call mkdir('bar')
115:cd ..
116:cd ..
117:" We should now be in the Xfind directory
118:e foo/x/bar/voyager.txt
119SVoyager 1:w
120:e foo/y/bar/voyager.txt
121SVoyager 2:w
122:exec "set path=" . cwd . "/Xfind/**"
123:find voyager	
124:exec "w >>" . test_out
125:find voyager		
126:exec "w >>" . test_out
127:"
128:" When current directory is .../foo/y/bar they should be shortened to (in
129:" order of appearance):
130:"
131:"    ./voyager.txt
132:"    x/bar/voyager.txt
133:cd foo
134:cd y
135:cd bar
136:find voyager	
137:exec "w >> " . test_out
138:find voyager		
139:exec "w >> " . test_out
140:" Check the opposite too:
141:cd ..
142:cd ..
143:cd x
144:cd bar
145:find voyager	
146:exec "w >> " . test_out
147:find voyager		
148:exec "w >> " . test_out
149:" Check for correct handling of shorten_fname()'s behavior on windows
150:exec "cd " . cwd . "/Xfind/in"
151:find file	
152:exec "w >>" . test_out
153:" Test for relative to current buffer 'path' item
154:exec "cd " . cwd . "/Xfind/"
155:set path=./path
156:" Open the file where Jimmy Hoffa is found
157:e in/file.txt
158:" Find the file containing 'E.T.' in the Xfind/in/path directory
159:find file	
160:exec "w >>" . test_out
161:q
162:exec "cd " . cwd
163:call DeleteDirectory("Xfind")
164:qa!
165ENDTEST
166
167