Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 1 | " Test for the search command |
| 2 | |
Bram Moolenaar | c3c766e | 2017-03-08 22:55:19 +0100 | [diff] [blame] | 3 | set belloff=all |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 4 | func Test_search_cmdline() |
| 5 | if !exists('+incsearch') |
| 6 | return |
| 7 | endif |
| 8 | " need to disable char_avail, |
| 9 | " so that expansion of commandline works |
| 10 | call test_disable_char_avail(1) |
| 11 | new |
| 12 | call setline(1, [' 1', ' 2 these', ' 3 the', ' 4 their', ' 5 there', ' 6 their', ' 7 the', ' 8 them', ' 9 these', ' 10 foobar']) |
| 13 | " Test 1 |
| 14 | " CTRL-N / CTRL-P skips through the previous search history |
| 15 | set noincsearch |
| 16 | :1 |
| 17 | call feedkeys("/foobar\<cr>", 'tx') |
| 18 | call feedkeys("/the\<cr>",'tx') |
| 19 | call assert_equal('the', @/) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 20 | call feedkeys("/thes\<C-P>\<C-P>\<cr>",'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 21 | call assert_equal('foobar', @/) |
| 22 | |
| 23 | " Test 2 |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 24 | " Ctrl-G goes from one match to the next |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 25 | " until the end of the buffer |
| 26 | set incsearch nowrapscan |
| 27 | :1 |
| 28 | " first match |
| 29 | call feedkeys("/the\<cr>", 'tx') |
| 30 | call assert_equal(' 2 these', getline('.')) |
| 31 | :1 |
| 32 | " second match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 33 | call feedkeys("/the\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 34 | call assert_equal(' 3 the', getline('.')) |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 35 | call assert_equal([0, 0, 0, 0], getpos('"')) |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 36 | :1 |
| 37 | " third match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 38 | call feedkeys("/the".repeat("\<C-G>", 2)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 39 | call assert_equal(' 4 their', getline('.')) |
| 40 | :1 |
| 41 | " fourth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 42 | call feedkeys("/the".repeat("\<C-G>", 3)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 43 | call assert_equal(' 5 there', getline('.')) |
| 44 | :1 |
| 45 | " fifth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 46 | call feedkeys("/the".repeat("\<C-G>", 4)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 47 | call assert_equal(' 6 their', getline('.')) |
| 48 | :1 |
| 49 | " sixth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 50 | call feedkeys("/the".repeat("\<C-G>", 5)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 51 | call assert_equal(' 7 the', getline('.')) |
| 52 | :1 |
| 53 | " seventh match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 54 | call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 55 | call assert_equal(' 8 them', getline('.')) |
| 56 | :1 |
| 57 | " eigth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 58 | call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 59 | call assert_equal(' 9 these', getline('.')) |
| 60 | :1 |
| 61 | " no further match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 62 | call feedkeys("/the".repeat("\<C-G>", 8)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 63 | call assert_equal(' 9 these', getline('.')) |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 64 | call assert_equal([0, 0, 0, 0], getpos('"')) |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 65 | |
| 66 | " Test 3 |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 67 | " Ctrl-G goes from one match to the next |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 68 | " and continues back at the top |
| 69 | set incsearch wrapscan |
| 70 | :1 |
| 71 | " first match |
| 72 | call feedkeys("/the\<cr>", 'tx') |
| 73 | call assert_equal(' 2 these', getline('.')) |
| 74 | :1 |
| 75 | " second match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 76 | call feedkeys("/the\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 77 | call assert_equal(' 3 the', getline('.')) |
| 78 | :1 |
| 79 | " third match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 80 | call feedkeys("/the".repeat("\<C-G>", 2)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 81 | call assert_equal(' 4 their', getline('.')) |
| 82 | :1 |
| 83 | " fourth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 84 | call feedkeys("/the".repeat("\<C-G>", 3)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 85 | call assert_equal(' 5 there', getline('.')) |
| 86 | :1 |
| 87 | " fifth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 88 | call feedkeys("/the".repeat("\<C-G>", 4)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 89 | call assert_equal(' 6 their', getline('.')) |
| 90 | :1 |
| 91 | " sixth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 92 | call feedkeys("/the".repeat("\<C-G>", 5)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 93 | call assert_equal(' 7 the', getline('.')) |
| 94 | :1 |
| 95 | " seventh match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 96 | call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 97 | call assert_equal(' 8 them', getline('.')) |
| 98 | :1 |
| 99 | " eigth match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 100 | call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 101 | call assert_equal(' 9 these', getline('.')) |
| 102 | :1 |
| 103 | " back at first match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 104 | call feedkeys("/the".repeat("\<C-G>", 8)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 105 | call assert_equal(' 2 these', getline('.')) |
| 106 | |
| 107 | " Test 4 |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 108 | " CTRL-T goes to the previous match |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 109 | set incsearch nowrapscan |
| 110 | $ |
| 111 | " first match |
| 112 | call feedkeys("?the\<cr>", 'tx') |
| 113 | call assert_equal(' 9 these', getline('.')) |
| 114 | $ |
| 115 | " first match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 116 | call feedkeys("?the\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 117 | call assert_equal(' 9 these', getline('.')) |
| 118 | $ |
| 119 | " second match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 120 | call feedkeys("?the".repeat("\<C-T>", 1)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 121 | call assert_equal(' 8 them', getline('.')) |
| 122 | $ |
| 123 | " last match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 124 | call feedkeys("?the".repeat("\<C-T>", 7)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 125 | call assert_equal(' 2 these', getline('.')) |
| 126 | $ |
| 127 | " last match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 128 | call feedkeys("?the".repeat("\<C-T>", 8)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 129 | call assert_equal(' 2 these', getline('.')) |
| 130 | |
| 131 | " Test 5 |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 132 | " CTRL-T goes to the previous match |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 133 | set incsearch wrapscan |
| 134 | $ |
| 135 | " first match |
| 136 | call feedkeys("?the\<cr>", 'tx') |
| 137 | call assert_equal(' 9 these', getline('.')) |
| 138 | $ |
| 139 | " first match at the top |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 140 | call feedkeys("?the\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 141 | call assert_equal(' 2 these', getline('.')) |
| 142 | $ |
| 143 | " second match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 144 | call feedkeys("?the".repeat("\<C-T>", 1)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 145 | call assert_equal(' 8 them', getline('.')) |
| 146 | $ |
| 147 | " last match |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 148 | call feedkeys("?the".repeat("\<C-T>", 7)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 149 | call assert_equal(' 2 these', getline('.')) |
| 150 | $ |
| 151 | " back at the bottom of the buffer |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 152 | call feedkeys("?the".repeat("\<C-T>", 8)."\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 153 | call assert_equal(' 9 these', getline('.')) |
| 154 | |
| 155 | " Test 6 |
| 156 | " CTRL-L adds to the search pattern |
| 157 | set incsearch wrapscan |
| 158 | 1 |
| 159 | " first match |
| 160 | call feedkeys("/the\<c-l>\<cr>", 'tx') |
| 161 | call assert_equal(' 2 these', getline('.')) |
| 162 | 1 |
| 163 | " go to next match of 'thes' |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 164 | call feedkeys("/the\<c-l>\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 165 | call assert_equal(' 9 these', getline('.')) |
| 166 | 1 |
| 167 | " wrap around |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 168 | call feedkeys("/the\<c-l>\<C-G>\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 169 | call assert_equal(' 2 these', getline('.')) |
| 170 | 1 |
| 171 | " wrap around |
| 172 | set nowrapscan |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 173 | call feedkeys("/the\<c-l>\<C-G>\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 174 | call assert_equal(' 9 these', getline('.')) |
| 175 | |
| 176 | " Test 7 |
| 177 | " <bs> remove from match, but stay at current match |
| 178 | set incsearch wrapscan |
| 179 | 1 |
| 180 | " first match |
| 181 | call feedkeys("/thei\<cr>", 'tx') |
| 182 | call assert_equal(' 4 their', getline('.')) |
| 183 | 1 |
| 184 | " delete one char, add another |
| 185 | call feedkeys("/thei\<bs>s\<cr>", 'tx') |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 186 | call assert_equal(' 2 these', getline('.')) |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 187 | 1 |
| 188 | " delete one char, add another, go to previous match, add one char |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 189 | call feedkeys("/thei\<bs>s\<bs>\<C-T>\<c-l>\<cr>", 'tx') |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 190 | call assert_equal(' 9 these', getline('.')) |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 191 | 1 |
| 192 | " delete all chars, start from the beginning again |
| 193 | call feedkeys("/them". repeat("\<bs>",4).'the\>'."\<cr>", 'tx') |
| 194 | call assert_equal(' 3 the', getline('.')) |
| 195 | |
| 196 | " clean up |
| 197 | call test_disable_char_avail(0) |
| 198 | bw! |
| 199 | endfunc |
| 200 | |
| 201 | func Test_search_cmdline2() |
| 202 | if !exists('+incsearch') |
| 203 | return |
| 204 | endif |
| 205 | " need to disable char_avail, |
| 206 | " so that expansion of commandline works |
| 207 | call test_disable_char_avail(1) |
| 208 | new |
| 209 | call setline(1, [' 1', ' 2 these', ' 3 the theother']) |
| 210 | " Test 1 |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 211 | " Ctrl-T goes correctly back and forth |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 212 | set incsearch |
| 213 | 1 |
| 214 | " first match |
| 215 | call feedkeys("/the\<cr>", 'tx') |
| 216 | call assert_equal(' 2 these', getline('.')) |
| 217 | 1 |
| 218 | " go to next match (on next line) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 219 | call feedkeys("/the\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 220 | call assert_equal(' 3 the theother', getline('.')) |
| 221 | 1 |
| 222 | " go to next match (still on line 3) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 223 | call feedkeys("/the\<C-G>\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 224 | call assert_equal(' 3 the theother', getline('.')) |
| 225 | 1 |
| 226 | " go to next match (still on line 3) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 227 | call feedkeys("/the\<C-G>\<C-G>\<C-G>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 228 | call assert_equal(' 3 the theother', getline('.')) |
| 229 | 1 |
| 230 | " go to previous match (on line 3) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 231 | call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 232 | call assert_equal(' 3 the theother', getline('.')) |
| 233 | 1 |
| 234 | " go to previous match (on line 3) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 235 | call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 236 | call assert_equal(' 3 the theother', getline('.')) |
| 237 | 1 |
| 238 | " go to previous match (on line 2) |
Bram Moolenaar | 1195669 | 2016-08-27 16:26:56 +0200 | [diff] [blame] | 239 | call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<C-T>\<cr>", 'tx') |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 240 | call assert_equal(' 2 these', getline('.')) |
| 241 | |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 242 | " Test 2: keep the view, |
| 243 | " after deleting a character from the search cmd |
| 244 | call setline(1, [' 1', ' 2 these', ' 3 the', ' 4 their', ' 5 there', ' 6 their', ' 7 the', ' 8 them', ' 9 these', ' 10 foobar']) |
| 245 | resize 5 |
| 246 | 1 |
| 247 | call feedkeys("/foo\<bs>\<cr>", 'tx') |
| 248 | redraw |
| 249 | call assert_equal({'lnum': 10, 'leftcol': 0, 'col': 4, 'topfill': 0, 'topline': 6, 'coladd': 0, 'skipcol': 0, 'curswant': 4}, winsaveview()) |
| 250 | |
| 251 | " remove all history entries |
| 252 | for i in range(10) |
| 253 | call histdel('/') |
| 254 | endfor |
| 255 | |
| 256 | " Test 3: reset the view, |
| 257 | " after deleting all characters from the search cmd |
| 258 | norm! 1gg0 |
| 259 | " unfortunately, neither "/foo\<c-w>\<cr>", nor "/foo\<bs>\<bs>\<bs>\<cr>", |
| 260 | " nor "/foo\<c-u>\<cr>" works to delete the commandline. |
| 261 | " In that case Vim should return "E35 no previous regular expression", |
| 262 | " but it looks like Vim still sees /foo and therefore the test fails. |
| 263 | " Therefore, disableing this test |
| 264 | "call assert_fails(feedkeys("/foo\<c-w>\<cr>", 'tx'), 'E35') |
| 265 | "call assert_equal({'lnum': 1, 'leftcol': 0, 'col': 0, 'topfill': 0, 'topline': 1, 'coladd': 0, 'skipcol': 0, 'curswant': 0}, winsaveview()) |
| 266 | |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 267 | " clean up |
Bram Moolenaar | dda933d | 2016-09-03 21:04:58 +0200 | [diff] [blame] | 268 | set noincsearch |
Bram Moolenaar | 4d6f32c | 2016-08-26 19:13:46 +0200 | [diff] [blame] | 269 | call test_disable_char_avail(0) |
| 270 | bw! |
| 271 | endfunc |
Bram Moolenaar | ea683da | 2016-09-09 21:41:34 +0200 | [diff] [blame] | 272 | |
| 273 | func Test_use_sub_pat() |
| 274 | split |
| 275 | let @/ = '' |
| 276 | func X() |
| 277 | s/^/a/ |
| 278 | / |
| 279 | endfunc |
| 280 | call X() |
| 281 | bwipe! |
| 282 | endfunc |
Bram Moolenaar | 6e450a5 | 2017-01-06 20:03:58 +0100 | [diff] [blame] | 283 | |
| 284 | func Test_searchpair() |
| 285 | new |
| 286 | call setline(1, ['other code here', '', '[', '" cursor here', ']']) |
| 287 | 4 |
| 288 | let a=searchpair('\[','',']','bW') |
| 289 | call assert_equal(3, a) |
| 290 | set nomagic |
| 291 | 4 |
| 292 | let a=searchpair('\[','',']','bW') |
| 293 | call assert_equal(3, a) |
| 294 | set magic |
| 295 | q! |
| 296 | endfunc |
| 297 | |
Bram Moolenaar | 66727e1 | 2017-03-01 22:17:05 +0100 | [diff] [blame] | 298 | func Test_searchc() |
| 299 | " These commands used to cause memory overflow in searchc(). |
| 300 | new |
| 301 | norm ixx |
| 302 | exe "norm 0t\u93cf" |
| 303 | bw! |
| 304 | endfunc |