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