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