Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 1 | " Tests for 'conceal'. |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 2 | |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 3 | source check.vim |
| 4 | CheckFeature conceal |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 5 | |
| 6 | source screendump.vim |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 7 | source view_util.vim |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 8 | |
| 9 | func Test_conceal_two_windows() |
zeertzjq | 2069191 | 2022-01-23 12:42:55 +0000 | [diff] [blame] | 10 | CheckScreendump |
| 11 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 12 | let code =<< trim [CODE] |
| 13 | let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"] |
| 14 | call setline(1, lines) |
| 15 | syntax match test /|hidden|/ conceal |
| 16 | set conceallevel=2 |
| 17 | set concealcursor= |
| 18 | exe "normal /here\r" |
| 19 | new |
| 20 | call setline(1, lines) |
| 21 | call setline(4, "Second window") |
| 22 | syntax match test /|hidden|/ conceal |
| 23 | set conceallevel=2 |
| 24 | set concealcursor=nc |
| 25 | exe "normal /here\r" |
| 26 | [CODE] |
| 27 | |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 28 | call writefile(code, 'XTest_conceal', 'D') |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 29 | " Check that cursor line is concealed |
| 30 | let buf = RunVimInTerminal('-S XTest_conceal', {}) |
| 31 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {}) |
| 32 | |
| 33 | " Check that with concealed text vertical cursor movement is correct. |
| 34 | call term_sendkeys(buf, "k") |
| 35 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_02', {}) |
| 36 | |
| 37 | " Check that with cursor line is not concealed |
| 38 | call term_sendkeys(buf, "j") |
| 39 | call term_sendkeys(buf, ":set concealcursor=\r") |
| 40 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_03', {}) |
| 41 | |
| 42 | " Check that with cursor line is not concealed when moving cursor down |
| 43 | call term_sendkeys(buf, "j") |
| 44 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_04', {}) |
| 45 | |
| 46 | " Check that with cursor line is not concealed when switching windows |
| 47 | call term_sendkeys(buf, "\<C-W>\<C-W>") |
| 48 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_05', {}) |
| 49 | |
| 50 | " Check that with cursor line is only concealed in Normal mode |
| 51 | call term_sendkeys(buf, ":set concealcursor=n\r") |
| 52 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06n', {}) |
| 53 | call term_sendkeys(buf, "a") |
| 54 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06i', {}) |
| 55 | call term_sendkeys(buf, "\<Esc>/e") |
| 56 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06c', {}) |
| 57 | call term_sendkeys(buf, "\<Esc>v") |
| 58 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06v', {}) |
| 59 | call term_sendkeys(buf, "\<Esc>") |
| 60 | |
| 61 | " Check that with cursor line is only concealed in Insert mode |
| 62 | call term_sendkeys(buf, ":set concealcursor=i\r") |
| 63 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07n', {}) |
Bram Moolenaar | 644b49f | 2021-09-16 22:32:15 +0200 | [diff] [blame] | 64 | call term_sendkeys(buf, "14|a") |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 65 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07i', {}) |
Bram Moolenaar | 644b49f | 2021-09-16 22:32:15 +0200 | [diff] [blame] | 66 | call term_sendkeys(buf, "\<Esc>") |
| 67 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07in', {}) |
| 68 | call term_sendkeys(buf, "/e") |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 69 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07c', {}) |
| 70 | call term_sendkeys(buf, "\<Esc>v") |
| 71 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07v', {}) |
| 72 | call term_sendkeys(buf, "\<Esc>") |
| 73 | |
| 74 | " Check that with cursor line is only concealed in Command mode |
| 75 | call term_sendkeys(buf, ":set concealcursor=c\r") |
| 76 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08n', {}) |
| 77 | call term_sendkeys(buf, "a") |
| 78 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08i', {}) |
| 79 | call term_sendkeys(buf, "\<Esc>/e") |
| 80 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08c', {}) |
| 81 | call term_sendkeys(buf, "\<Esc>v") |
| 82 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08v', {}) |
| 83 | call term_sendkeys(buf, "\<Esc>") |
| 84 | |
| 85 | " Check that with cursor line is only concealed in Visual mode |
| 86 | call term_sendkeys(buf, ":set concealcursor=v\r") |
| 87 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09n', {}) |
| 88 | call term_sendkeys(buf, "a") |
| 89 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09i', {}) |
| 90 | call term_sendkeys(buf, "\<Esc>/e") |
| 91 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09c', {}) |
| 92 | call term_sendkeys(buf, "\<Esc>v") |
| 93 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09v', {}) |
| 94 | call term_sendkeys(buf, "\<Esc>") |
| 95 | |
Bram Moolenaar | 465e8b5 | 2019-01-11 20:42:28 +0100 | [diff] [blame] | 96 | " Check moving the cursor while in insert mode. |
| 97 | call term_sendkeys(buf, ":set concealcursor=\r") |
| 98 | call term_sendkeys(buf, "a") |
| 99 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_10', {}) |
| 100 | call term_sendkeys(buf, "\<Down>") |
| 101 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_11', {}) |
| 102 | call term_sendkeys(buf, "\<Esc>") |
| 103 | |
| 104 | " Check the "o" command |
| 105 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_12', {}) |
| 106 | call term_sendkeys(buf, "o") |
| 107 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_13', {}) |
| 108 | call term_sendkeys(buf, "\<Esc>") |
| 109 | |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 110 | " clean up |
| 111 | call StopVimInTerminal(buf) |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 112 | endfunc |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 113 | |
| 114 | func Test_conceal_with_cursorline() |
zeertzjq | 2069191 | 2022-01-23 12:42:55 +0000 | [diff] [blame] | 115 | CheckScreendump |
| 116 | |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 117 | " Opens a help window, where 'conceal' is set, switches to the other window |
| 118 | " where 'cursorline' needs to be updated when the cursor moves. |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 119 | let code =<< trim [CODE] |
| 120 | set cursorline |
| 121 | normal othis is a test |
| 122 | new |
| 123 | call setline(1, ["one", "two", "three", "four", "five"]) |
| 124 | set ft=help |
| 125 | normal M |
| 126 | [CODE] |
| 127 | |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 128 | call writefile(code, 'XTest_conceal_cul', 'D') |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 129 | let buf = RunVimInTerminal('-S XTest_conceal_cul', {}) |
| 130 | call VerifyScreenDump(buf, 'Test_conceal_cul_01', {}) |
| 131 | |
| 132 | call term_sendkeys(buf, ":wincmd w\r") |
| 133 | call VerifyScreenDump(buf, 'Test_conceal_cul_02', {}) |
| 134 | |
| 135 | call term_sendkeys(buf, "k") |
| 136 | call VerifyScreenDump(buf, 'Test_conceal_cul_03', {}) |
| 137 | |
| 138 | " clean up |
| 139 | call StopVimInTerminal(buf) |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 140 | endfunc |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 141 | |
Alexey Radkov | aaa16b0 | 2023-01-04 11:15:30 +0000 | [diff] [blame] | 142 | func Test_conceal_with_cursorcolumn() |
| 143 | CheckScreendump |
| 144 | |
| 145 | " Check that cursorcolumn and colorcolumn don't get broken in presence of |
| 146 | " wrapped lines containing concealed text |
| 147 | let code =<< trim [CODE] |
| 148 | let lines = ["one one one |hidden| one one one one one one one one", |
| 149 | \ "two two two two |hidden| here two two", |
| 150 | \ "three |hidden| three three three three three three three three"] |
| 151 | call setline(1, lines) |
| 152 | set wrap linebreak |
| 153 | set showbreak=\ >>>\ |
| 154 | syntax match test /|hidden|/ conceal |
| 155 | set conceallevel=2 |
| 156 | set concealcursor= |
| 157 | exe "normal /here\r" |
| 158 | set cursorcolumn |
| 159 | set colorcolumn=50 |
| 160 | [CODE] |
| 161 | |
| 162 | call writefile(code, 'XTest_conceal_cuc', 'D') |
| 163 | let buf = RunVimInTerminal('-S XTest_conceal_cuc', {'rows': 10, 'cols': 40}) |
| 164 | call VerifyScreenDump(buf, 'Test_conceal_cuc_01', {}) |
| 165 | |
| 166 | " move cursor to the end of line (the cursor jumps to the next screen line) |
| 167 | call term_sendkeys(buf, "$") |
| 168 | call VerifyScreenDump(buf, 'Test_conceal_cuc_02', {}) |
| 169 | |
| 170 | " clean up |
| 171 | call StopVimInTerminal(buf) |
| 172 | endfunc |
| 173 | |
zeertzjq | 21b0a3d | 2024-03-13 20:06:34 +0100 | [diff] [blame] | 174 | " Check that 'cursorline' and 'wincolor' apply to the whole line in presence |
| 175 | " of wrapped lines containing concealed text. |
| 176 | func Test_conceal_wrapped_cursorline_wincolor() |
| 177 | CheckScreendump |
| 178 | |
| 179 | let code =<< trim [CODE] |
| 180 | call setline(1, 'one one one |hidden| one one one one one one one one') |
| 181 | syntax match test /|hidden|/ conceal |
| 182 | set conceallevel=2 concealcursor=n cursorline |
| 183 | normal! g$ |
| 184 | [CODE] |
| 185 | |
| 186 | call writefile(code, 'XTest_conceal_cul_wcr', 'D') |
| 187 | let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr', {'rows': 4, 'cols': 40}) |
| 188 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_01', {}) |
| 189 | |
| 190 | call term_sendkeys(buf, ":set wincolor=ErrorMsg\n") |
| 191 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_02', {}) |
| 192 | |
| 193 | call term_sendkeys(buf, ":set nocursorline\n") |
| 194 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_03', {}) |
| 195 | |
| 196 | " clean up |
| 197 | call StopVimInTerminal(buf) |
| 198 | endfunc |
| 199 | |
| 200 | " Same as Test_conceal_wrapped_cursorline_wincolor(), but with 'rightleft'. |
| 201 | func Test_conceal_wrapped_cursorline_wincolor_rightleft() |
| 202 | CheckScreendump |
| 203 | |
| 204 | let code =<< trim [CODE] |
| 205 | call setline(1, 'one one one |hidden| one one one one one one one one') |
| 206 | syntax match test /|hidden|/ conceal |
| 207 | set conceallevel=2 concealcursor=n cursorline rightleft |
| 208 | normal! g$ |
| 209 | [CODE] |
| 210 | |
| 211 | call writefile(code, 'XTest_conceal_cul_wcr_rl', 'D') |
| 212 | let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr_rl', {'rows': 4, 'cols': 40}) |
| 213 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_01', {}) |
| 214 | |
| 215 | call term_sendkeys(buf, ":set wincolor=ErrorMsg\n") |
| 216 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_02', {}) |
| 217 | |
| 218 | call term_sendkeys(buf, ":set nocursorline\n") |
| 219 | call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_03', {}) |
| 220 | |
| 221 | " clean up |
| 222 | call StopVimInTerminal(buf) |
| 223 | endfunc |
| 224 | |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 225 | func Test_conceal_resize_term() |
zeertzjq | 2069191 | 2022-01-23 12:42:55 +0000 | [diff] [blame] | 226 | CheckScreendump |
| 227 | |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 228 | let code =<< trim [CODE] |
| 229 | call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed') |
| 230 | setl cocu=n cole=3 |
| 231 | syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends |
| 232 | normal fb |
| 233 | [CODE] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 234 | call writefile(code, 'XTest_conceal_resize', 'D') |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 235 | let buf = RunVimInTerminal('-S XTest_conceal_resize', {'rows': 6}) |
| 236 | call VerifyScreenDump(buf, 'Test_conceal_resize_01', {}) |
| 237 | |
| 238 | call win_execute(buf->win_findbuf()[0], 'wincmd +') |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 239 | call VerifyScreenDump(buf, 'Test_conceal_resize_02', {}) |
| 240 | |
| 241 | " clean up |
| 242 | call StopVimInTerminal(buf) |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 243 | endfunc |
Bram Moolenaar | 213ed00 | 2019-12-11 20:12:26 +0100 | [diff] [blame] | 244 | |
Bram Moolenaar | 7500866 | 2022-10-04 22:40:56 +0100 | [diff] [blame] | 245 | func Test_conceal_linebreak() |
| 246 | CheckScreendump |
| 247 | |
| 248 | let code =<< trim [CODE] |
| 249 | vim9script |
| 250 | &wrap = true |
| 251 | &conceallevel = 2 |
| 252 | &concealcursor = 'nc' |
| 253 | &linebreak = true |
| 254 | &showbreak = '+ ' |
| 255 | var line: string = 'a`a`a`a`' |
| 256 | .. 'a'->repeat(&columns - 15) |
| 257 | .. ' b`b`' |
| 258 | .. 'b'->repeat(&columns - 10) |
| 259 | .. ' cccccc' |
| 260 | ['x'->repeat(&columns), '', line]->setline(1) |
| 261 | syntax region CodeSpan matchgroup=Delimiter start=/\z(`\+\)/ end=/\z1/ concealends |
| 262 | [CODE] |
| 263 | call writefile(code, 'XTest_conceal_linebreak', 'D') |
| 264 | let buf = RunVimInTerminal('-S XTest_conceal_linebreak', {'rows': 8}) |
| 265 | call VerifyScreenDump(buf, 'Test_conceal_linebreak_1', {}) |
| 266 | |
| 267 | " clean up |
| 268 | call StopVimInTerminal(buf) |
| 269 | endfunc |
| 270 | |
Bram Moolenaar | 213ed00 | 2019-12-11 20:12:26 +0100 | [diff] [blame] | 271 | " Tests for correct display (cursor column position) with +conceal and |
| 272 | " tabulators. Need to run this test in a separate Vim instance. Otherwise the |
| 273 | " screen is not updated (lazy redraw) and the cursor position is wrong. |
| 274 | func Test_conceal_cursor_pos() |
| 275 | let code =<< trim [CODE] |
| 276 | :let l = ['start:', '.concealed. text', "|concealed|\ttext"] |
| 277 | :let l += ['', "\t.concealed.\ttext", "\t|concealed|\ttext", ''] |
| 278 | :let l += [".a.\t.b.\t.c.\t.d.", "|a|\t|b|\t|c|\t|d|"] |
| 279 | :call append(0, l) |
| 280 | :call cursor(1, 1) |
| 281 | :" Conceal settings. |
| 282 | :set conceallevel=2 |
| 283 | :set concealcursor=nc |
| 284 | :syntax match test /|/ conceal |
| 285 | :" Save current cursor position. Only works in <expr> mode, can't be used |
| 286 | :" with :normal because it moves the cursor to the command line. Thanks |
| 287 | :" to ZyX <zyx.vim@gmail.com> for the idea to use an <expr> mapping. |
| 288 | :let curpos = [] |
| 289 | :nnoremap <expr> GG ":let curpos += ['".screenrow().":".screencol()."']\n" |
| 290 | :normal ztj |
| 291 | GGk |
| 292 | :" We should end up in the same column when running these commands on the |
| 293 | :" two lines. |
| 294 | :normal ft |
| 295 | GGk |
| 296 | :normal $ |
| 297 | GGk |
| 298 | :normal 0j |
| 299 | GGk |
| 300 | :normal ft |
| 301 | GGk |
| 302 | :normal $ |
| 303 | GGk |
| 304 | :normal 0j0j |
| 305 | GGk |
| 306 | :" Same for next test block. |
| 307 | :normal ft |
| 308 | GGk |
| 309 | :normal $ |
| 310 | GGk |
| 311 | :normal 0j |
| 312 | GGk |
| 313 | :normal ft |
| 314 | GGk |
| 315 | :normal $ |
| 316 | GGk |
| 317 | :normal 0j0j |
| 318 | GGk |
| 319 | :" And check W with multiple tabs and conceals in a line. |
| 320 | :normal W |
| 321 | GGk |
| 322 | :normal W |
| 323 | GGk |
| 324 | :normal W |
| 325 | GGk |
| 326 | :normal $ |
| 327 | GGk |
| 328 | :normal 0j |
| 329 | GGk |
| 330 | :normal W |
| 331 | GGk |
| 332 | :normal W |
| 333 | GGk |
| 334 | :normal W |
| 335 | GGk |
| 336 | :normal $ |
| 337 | GGk |
| 338 | :set lbr |
| 339 | :normal $ |
| 340 | GGk |
| 341 | :set list listchars=tab:>- |
| 342 | :normal 0 |
| 343 | GGk |
| 344 | :normal W |
| 345 | GGk |
| 346 | :normal W |
| 347 | GGk |
| 348 | :normal W |
| 349 | GGk |
| 350 | :normal $ |
| 351 | GGk |
| 352 | :call writefile(curpos, 'Xconceal_curpos.out') |
| 353 | :q! |
| 354 | |
| 355 | [CODE] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 356 | call writefile(code, 'XTest_conceal_curpos', 'D') |
Bram Moolenaar | 213ed00 | 2019-12-11 20:12:26 +0100 | [diff] [blame] | 357 | |
| 358 | if RunVim([], [], '-s XTest_conceal_curpos') |
| 359 | call assert_equal([ |
| 360 | \ '2:1', '2:17', '2:20', '3:1', '3:17', '3:20', '5:8', '5:25', |
| 361 | \ '5:28', '6:8', '6:25', '6:28', '8:1', '8:9', '8:17', '8:25', |
| 362 | \ '8:27', '9:1', '9:9', '9:17', '9:25', '9:26', '9:26', '9:1', |
| 363 | \ '9:9', '9:17', '9:25', '9:26'], readfile('Xconceal_curpos.out')) |
| 364 | endif |
| 365 | |
| 366 | call delete('Xconceal_curpos.out') |
Bram Moolenaar | 213ed00 | 2019-12-11 20:12:26 +0100 | [diff] [blame] | 367 | endfunc |
| 368 | |
Bram Moolenaar | fc838d6 | 2020-06-25 22:23:48 +0200 | [diff] [blame] | 369 | func Test_conceal_eol() |
| 370 | new! |
| 371 | setlocal concealcursor=n conceallevel=1 |
| 372 | call setline(1, ["x", ""]) |
| 373 | call matchaddpos('Conceal', [[2, 1, 1]], 2, -1, {'conceal': 1}) |
| 374 | redraw! |
| 375 | |
| 376 | call assert_notequal(screenchar(1, 1), screenchar(2, 2)) |
| 377 | call assert_equal(screenattr(1, 1), screenattr(1, 2)) |
| 378 | call assert_equal(screenattr(1, 2), screenattr(2, 2)) |
| 379 | call assert_equal(screenattr(2, 1), screenattr(2, 2)) |
| 380 | |
| 381 | set list |
| 382 | redraw! |
| 383 | |
| 384 | call assert_equal(screenattr(1, 1), screenattr(2, 2)) |
| 385 | call assert_notequal(screenattr(1, 1), screenattr(1, 2)) |
| 386 | call assert_notequal(screenattr(1, 2), screenattr(2, 1)) |
| 387 | |
| 388 | set nolist |
| 389 | endfunc |
| 390 | |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 391 | func Test_conceal_mouse_click() |
| 392 | enew! |
| 393 | set mouse=a |
| 394 | setlocal conceallevel=2 concealcursor=nc |
| 395 | syn match Concealed "this" conceal |
| 396 | hi link Concealed Search |
| 397 | call setline(1, 'conceal this click here') |
| 398 | redraw |
| 399 | call assert_equal(['conceal click here '], ScreenLines(1, 20)) |
| 400 | |
zeertzjq | fc30584 | 2023-08-19 13:27:03 +0200 | [diff] [blame] | 401 | " click on the space between "this" and "click" puts cursor there |
| 402 | call test_setmouse(1, 9) |
| 403 | call feedkeys("\<LeftMouse>", "tx") |
| 404 | call assert_equal([0, 1, 13, 0, 13], getcurpos()) |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 405 | " click on 'h' of "here" puts cursor there |
| 406 | call test_setmouse(1, 16) |
| 407 | call feedkeys("\<LeftMouse>", "tx") |
| 408 | call assert_equal([0, 1, 20, 0, 20], getcurpos()) |
zeertzjq | e500ae8 | 2023-08-17 22:35:26 +0200 | [diff] [blame] | 409 | " click on 'e' of "here" puts cursor there |
| 410 | call test_setmouse(1, 19) |
| 411 | call feedkeys("\<LeftMouse>", "tx") |
| 412 | call assert_equal([0, 1, 23, 0, 23], getcurpos()) |
| 413 | " click after end of line puts cursor on 'e' without 'virtualedit' |
| 414 | call test_setmouse(1, 20) |
| 415 | call feedkeys("\<LeftMouse>", "tx") |
| 416 | call assert_equal([0, 1, 23, 0, 24], getcurpos()) |
| 417 | call test_setmouse(1, 21) |
| 418 | call feedkeys("\<LeftMouse>", "tx") |
| 419 | call assert_equal([0, 1, 23, 0, 25], getcurpos()) |
| 420 | call test_setmouse(1, 22) |
| 421 | call feedkeys("\<LeftMouse>", "tx") |
| 422 | call assert_equal([0, 1, 23, 0, 26], getcurpos()) |
| 423 | call test_setmouse(1, 31) |
| 424 | call feedkeys("\<LeftMouse>", "tx") |
| 425 | call assert_equal([0, 1, 23, 0, 35], getcurpos()) |
| 426 | call test_setmouse(1, 32) |
| 427 | call feedkeys("\<LeftMouse>", "tx") |
| 428 | call assert_equal([0, 1, 23, 0, 36], getcurpos()) |
| 429 | |
| 430 | set virtualedit=all |
zeertzjq | fc30584 | 2023-08-19 13:27:03 +0200 | [diff] [blame] | 431 | redraw |
| 432 | " click on the space between "this" and "click" puts cursor there |
| 433 | call test_setmouse(1, 9) |
| 434 | call feedkeys("\<LeftMouse>", "tx") |
| 435 | call assert_equal([0, 1, 13, 0, 13], getcurpos()) |
zeertzjq | e500ae8 | 2023-08-17 22:35:26 +0200 | [diff] [blame] | 436 | " click on 'h' of "here" puts cursor there |
| 437 | call test_setmouse(1, 16) |
| 438 | call feedkeys("\<LeftMouse>", "tx") |
| 439 | call assert_equal([0, 1, 20, 0, 20], getcurpos()) |
| 440 | " click on 'e' of "here" puts cursor there |
| 441 | call test_setmouse(1, 19) |
| 442 | call feedkeys("\<LeftMouse>", "tx") |
| 443 | call assert_equal([0, 1, 23, 0, 23], getcurpos()) |
| 444 | " click after end of line puts cursor there without 'virtualedit' |
| 445 | call test_setmouse(1, 20) |
| 446 | call feedkeys("\<LeftMouse>", "tx") |
| 447 | call assert_equal([0, 1, 24, 0, 24], getcurpos()) |
| 448 | call test_setmouse(1, 21) |
| 449 | call feedkeys("\<LeftMouse>", "tx") |
| 450 | call assert_equal([0, 1, 24, 1, 25], getcurpos()) |
| 451 | call test_setmouse(1, 22) |
| 452 | call feedkeys("\<LeftMouse>", "tx") |
| 453 | call assert_equal([0, 1, 24, 2, 26], getcurpos()) |
| 454 | call test_setmouse(1, 31) |
| 455 | call feedkeys("\<LeftMouse>", "tx") |
| 456 | call assert_equal([0, 1, 24, 11, 35], getcurpos()) |
| 457 | call test_setmouse(1, 32) |
| 458 | call feedkeys("\<LeftMouse>", "tx") |
| 459 | call assert_equal([0, 1, 24, 12, 36], getcurpos()) |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 460 | |
| 461 | bwipe! |
zeertzjq | e500ae8 | 2023-08-17 22:35:26 +0200 | [diff] [blame] | 462 | set mouse& virtualedit& |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 463 | endfunc |
| 464 | |
zeertzjq | 253ff4d | 2024-03-13 20:38:26 +0100 | [diff] [blame] | 465 | " Test that cursor is drawn at the correct column when it is after end of the |
| 466 | " line with 'virtualedit' and concealing. |
| 467 | func Test_conceal_virtualedit_after_eol() |
| 468 | CheckScreendump |
| 469 | |
| 470 | let code =<< trim [CODE] |
| 471 | call setline(1, 'abcdefgh|hidden|ijklmnpop') |
| 472 | syntax match test /|hidden|/ conceal |
| 473 | set conceallevel=2 concealcursor=n virtualedit=all |
| 474 | normal! $ |
| 475 | [CODE] |
| 476 | call writefile(code, 'XTest_conceal_ve_after_eol', 'D') |
| 477 | let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol', {'rows': 3}) |
| 478 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_1', {}) |
| 479 | call term_sendkeys(buf, "l") |
| 480 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_2', {}) |
| 481 | call term_sendkeys(buf, "l") |
| 482 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_3', {}) |
| 483 | call term_sendkeys(buf, "l") |
| 484 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_4', {}) |
| 485 | call term_sendkeys(buf, "rr") |
| 486 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_5', {}) |
| 487 | |
| 488 | " clean up |
| 489 | call StopVimInTerminal(buf) |
| 490 | endfunc |
| 491 | |
| 492 | " Same as Test_conceal_virtualedit_after_eol(), but with 'rightleft' set. |
| 493 | func Test_conceal_virtualedit_after_eol_rightleft() |
| 494 | CheckFeature rightleft |
| 495 | CheckScreendump |
| 496 | |
| 497 | let code =<< trim [CODE] |
| 498 | call setline(1, 'abcdefgh|hidden|ijklmnpop') |
| 499 | syntax match test /|hidden|/ conceal |
| 500 | set conceallevel=2 concealcursor=n virtualedit=all rightleft |
| 501 | normal! $ |
| 502 | [CODE] |
| 503 | call writefile(code, 'XTest_conceal_ve_after_eol_rl', 'D') |
| 504 | let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol_rl', {'rows': 3}) |
| 505 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_1', {}) |
| 506 | call term_sendkeys(buf, "h") |
| 507 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_2', {}) |
| 508 | call term_sendkeys(buf, "h") |
| 509 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_3', {}) |
| 510 | call term_sendkeys(buf, "h") |
| 511 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_4', {}) |
| 512 | call term_sendkeys(buf, "rr") |
| 513 | call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_5', {}) |
| 514 | |
| 515 | " clean up |
| 516 | call StopVimInTerminal(buf) |
| 517 | endfunc |
| 518 | |
Bram Moolenaar | 213ed00 | 2019-12-11 20:12:26 +0100 | [diff] [blame] | 519 | " vim: shiftwidth=2 sts=2 expandtab |