Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 1 | " Tests for ":highlight" and highlighting. |
| 2 | |
| 3 | source view_util.vim |
| 4 | |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 5 | func Test_highlight() |
| 6 | " basic test if ":highlight" doesn't crash |
| 7 | highlight |
| 8 | hi Search |
| 9 | |
| 10 | " test setting colors. |
| 11 | " test clearing one color and all doesn't generate error or warning |
| 12 | silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan |
| 13 | silent! hi Group2 term= cterm= |
| 14 | hi Group3 term=underline cterm=bold |
| 15 | |
| 16 | let res = split(execute("hi NewGroup"), "\n")[0] |
| 17 | " filter ctermfg and ctermbg, the numbers depend on the terminal |
| 18 | let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '') |
| 19 | let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '') |
| 20 | call assert_equal("NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3", |
| 21 | \ res) |
| 22 | call assert_equal("Group2 xxx cleared", |
| 23 | \ split(execute("hi Group2"), "\n")[0]) |
| 24 | call assert_equal("Group3 xxx term=underline cterm=bold", |
| 25 | \ split(execute("hi Group3"), "\n")[0]) |
| 26 | |
| 27 | hi clear NewGroup |
| 28 | call assert_equal("NewGroup xxx cleared", |
| 29 | \ split(execute("hi NewGroup"), "\n")[0]) |
| 30 | call assert_equal("Group2 xxx cleared", |
| 31 | \ split(execute("hi Group2"), "\n")[0]) |
| 32 | hi Group2 NONE |
| 33 | call assert_equal("Group2 xxx cleared", |
| 34 | \ split(execute("hi Group2"), "\n")[0]) |
| 35 | hi clear |
| 36 | call assert_equal("Group3 xxx cleared", |
| 37 | \ split(execute("hi Group3"), "\n")[0]) |
| 38 | call assert_fails("hi Crash term='asdf", "E475:") |
| 39 | endfunc |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 40 | |
| 41 | function! HighlightArgs(name) |
| 42 | return 'hi ' . substitute(split(execute('hi ' . a:name), '\n')[0], '\<xxx\>', '', '') |
| 43 | endfunction |
| 44 | |
| 45 | function! IsColorable() |
| 46 | return has('gui_running') || str2nr(&t_Co) >= 8 |
| 47 | endfunction |
| 48 | |
| 49 | function! HiCursorLine() |
| 50 | let hiCursorLine = HighlightArgs('CursorLine') |
| 51 | if has('gui_running') |
| 52 | let guibg = matchstr(hiCursorLine, 'guibg=\w\+') |
| 53 | let hi_ul = 'hi CursorLine gui=underline guibg=NONE' |
| 54 | let hi_bg = 'hi CursorLine gui=NONE ' . guibg |
| 55 | else |
| 56 | let hi_ul = 'hi CursorLine cterm=underline ctermbg=NONE' |
| 57 | let hi_bg = 'hi CursorLine cterm=NONE ctermbg=Gray' |
| 58 | endif |
| 59 | return [hiCursorLine, hi_ul, hi_bg] |
| 60 | endfunction |
| 61 | |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 62 | function! Check_lcs_eol_attrs(attrs, row, col) |
| 63 | let save_lcs = &lcs |
| 64 | set list |
| 65 | |
| 66 | call assert_equal(a:attrs, ScreenAttrs(a:row, a:col)[0]) |
| 67 | |
| 68 | set nolist |
| 69 | let &lcs = save_lcs |
| 70 | endfunction |
| 71 | |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 72 | func Test_highlight_eol_with_cursorline() |
| 73 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 74 | |
| 75 | call NewWindow('topleft 5', 20) |
| 76 | call setline(1, 'abcd') |
| 77 | call matchadd('Search', '\n') |
| 78 | |
| 79 | " expected: |
| 80 | " 'abcd ' |
| 81 | " ^^^^ ^^^^^ no highlight |
| 82 | " ^ 'Search' highlight |
| 83 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 84 | call assert_equal(repeat([attrs0[0]], 4), attrs0[0:3]) |
| 85 | call assert_equal(repeat([attrs0[0]], 5), attrs0[5:9]) |
| 86 | call assert_notequal(attrs0[0], attrs0[4]) |
| 87 | |
| 88 | setlocal cursorline |
| 89 | |
| 90 | " underline |
| 91 | exe hi_ul |
| 92 | |
| 93 | " expected: |
| 94 | " 'abcd ' |
| 95 | " ^^^^ underline |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 96 | " ^ 'Search' highlight with underline |
| 97 | " ^^^^^ underline |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 98 | let attrs = ScreenAttrs(1, 10)[0] |
| 99 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 100 | call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9]) |
| 101 | call assert_notequal(attrs[0], attrs[4]) |
| 102 | call assert_notequal(attrs[4], attrs[5]) |
| 103 | call assert_notequal(attrs0[0], attrs[0]) |
| 104 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 105 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 106 | |
| 107 | if IsColorable() |
| 108 | " bg-color |
| 109 | exe hi_bg |
| 110 | |
| 111 | " expected: |
| 112 | " 'abcd ' |
| 113 | " ^^^^ bg-color of 'CursorLine' |
| 114 | " ^ 'Search' highlight |
| 115 | " ^^^^^ bg-color of 'CursorLine' |
| 116 | let attrs = ScreenAttrs(1, 10)[0] |
| 117 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 118 | call assert_equal(repeat([attrs[5]], 5), attrs[5:9]) |
| 119 | call assert_equal(attrs0[4], attrs[4]) |
| 120 | call assert_notequal(attrs[0], attrs[4]) |
| 121 | call assert_notequal(attrs[4], attrs[5]) |
| 122 | call assert_notequal(attrs0[0], attrs[0]) |
| 123 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 124 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 125 | endif |
| 126 | |
| 127 | call CloseWindow() |
| 128 | exe hiCursorLine |
| 129 | endfunc |
| 130 | |
| 131 | func Test_highlight_eol_with_cursorline_vertsplit() |
| 132 | if !has('vertsplit') |
| 133 | return |
| 134 | endif |
| 135 | |
| 136 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 137 | |
| 138 | call NewWindow('topleft 5', 5) |
| 139 | call setline(1, 'abcd') |
| 140 | call matchadd('Search', '\n') |
| 141 | |
| 142 | let expected = "abcd |abcd " |
| 143 | let actual = ScreenLines(1, 15)[0] |
| 144 | call assert_equal(expected, actual) |
| 145 | |
| 146 | " expected: |
| 147 | " 'abcd |abcd ' |
| 148 | " ^^^^ ^^^^^^^^^ no highlight |
| 149 | " ^ 'Search' highlight |
| 150 | " ^ 'VertSplit' highlight |
| 151 | let attrs0 = ScreenAttrs(1, 15)[0] |
| 152 | call assert_equal(repeat([attrs0[0]], 4), attrs0[0:3]) |
| 153 | call assert_equal(repeat([attrs0[0]], 9), attrs0[6:14]) |
| 154 | call assert_notequal(attrs0[0], attrs0[4]) |
| 155 | call assert_notequal(attrs0[0], attrs0[5]) |
| 156 | call assert_notequal(attrs0[4], attrs0[5]) |
| 157 | |
| 158 | setlocal cursorline |
| 159 | |
| 160 | " expected: |
| 161 | " 'abcd |abcd ' |
| 162 | " ^^^^ underline |
| 163 | " ^ 'Search' highlight with underline |
| 164 | " ^ 'VertSplit' highlight |
| 165 | " ^^^^^^^^^ no highlight |
| 166 | |
| 167 | " underline |
| 168 | exe hi_ul |
| 169 | |
| 170 | let actual = ScreenLines(1, 15)[0] |
| 171 | call assert_equal(expected, actual) |
| 172 | |
| 173 | let attrs = ScreenAttrs(1, 15)[0] |
| 174 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 175 | call assert_equal(repeat([attrs[6]], 9), attrs[6:14]) |
| 176 | call assert_equal(attrs0[5:14], attrs[5:14]) |
| 177 | call assert_notequal(attrs[0], attrs[4]) |
| 178 | call assert_notequal(attrs[0], attrs[5]) |
| 179 | call assert_notequal(attrs[0], attrs[6]) |
| 180 | call assert_notequal(attrs[4], attrs[5]) |
| 181 | call assert_notequal(attrs[5], attrs[6]) |
| 182 | call assert_notequal(attrs0[0], attrs[0]) |
| 183 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 184 | call Check_lcs_eol_attrs(attrs, 1, 15) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 185 | |
| 186 | if IsColorable() |
| 187 | " bg-color |
| 188 | exe hi_bg |
| 189 | |
| 190 | let actual = ScreenLines(1, 15)[0] |
| 191 | call assert_equal(expected, actual) |
| 192 | |
| 193 | let attrs = ScreenAttrs(1, 15)[0] |
| 194 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 195 | call assert_equal(repeat([attrs[6]], 9), attrs[6:14]) |
| 196 | call assert_equal(attrs0[5:14], attrs[5:14]) |
| 197 | call assert_notequal(attrs[0], attrs[4]) |
| 198 | call assert_notequal(attrs[0], attrs[5]) |
| 199 | call assert_notequal(attrs[0], attrs[6]) |
| 200 | call assert_notequal(attrs[4], attrs[5]) |
| 201 | call assert_notequal(attrs[5], attrs[6]) |
| 202 | call assert_notequal(attrs0[0], attrs[0]) |
| 203 | call assert_equal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 204 | call Check_lcs_eol_attrs(attrs, 1, 15) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 205 | endif |
| 206 | |
| 207 | call CloseWindow() |
| 208 | exe hiCursorLine |
| 209 | endfunc |
| 210 | |
| 211 | func Test_highlight_eol_with_cursorline_rightleft() |
| 212 | if !has('rightleft') |
| 213 | return |
| 214 | endif |
| 215 | |
| 216 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 217 | |
| 218 | call NewWindow('topleft 5', 10) |
| 219 | setlocal rightleft |
| 220 | call setline(1, 'abcd') |
| 221 | call matchadd('Search', '\n') |
| 222 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 223 | |
| 224 | setlocal cursorline |
| 225 | |
| 226 | " underline |
| 227 | exe hi_ul |
| 228 | |
| 229 | " expected: |
| 230 | " ' dcba' |
| 231 | " ^^^^ underline |
| 232 | " ^ 'Search' highlight with underline |
| 233 | " ^^^^^ underline |
| 234 | let attrs = ScreenAttrs(1, 10)[0] |
| 235 | call assert_equal(repeat([attrs[9]], 4), attrs[6:9]) |
| 236 | call assert_equal(repeat([attrs[4]], 5) + [attrs[5]], attrs[0:5]) |
| 237 | call assert_notequal(attrs[9], attrs[5]) |
| 238 | call assert_notequal(attrs[4], attrs[5]) |
| 239 | call assert_notequal(attrs0[9], attrs[9]) |
| 240 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 241 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 242 | |
| 243 | if IsColorable() |
| 244 | " bg-color |
| 245 | exe hi_bg |
| 246 | |
| 247 | " expected: |
| 248 | " ' dcba' |
| 249 | " ^^^^ bg-color of 'CursorLine' |
| 250 | " ^ 'Search' highlight |
| 251 | " ^^^^^ bg-color of 'CursorLine' |
| 252 | let attrs = ScreenAttrs(1, 10)[0] |
| 253 | call assert_equal(repeat([attrs[9]], 4), attrs[6:9]) |
| 254 | call assert_equal(repeat([attrs[4]], 5), attrs[0:4]) |
| 255 | call assert_equal(attrs0[5], attrs[5]) |
| 256 | call assert_notequal(attrs[9], attrs[5]) |
| 257 | call assert_notequal(attrs[5], attrs[4]) |
| 258 | call assert_notequal(attrs0[9], attrs[9]) |
| 259 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 260 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 261 | endif |
| 262 | |
| 263 | call CloseWindow() |
| 264 | exe hiCursorLine |
| 265 | endfunc |
| 266 | |
| 267 | func Test_highlight_eol_with_cursorline_linewrap() |
| 268 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 269 | |
| 270 | call NewWindow('topleft 5', 10) |
| 271 | call setline(1, [repeat('a', 51) . 'bcd', '']) |
| 272 | call matchadd('Search', '\n') |
| 273 | |
| 274 | setlocal wrap |
| 275 | normal! gg$ |
| 276 | let attrs0 = ScreenAttrs(5, 10)[0] |
| 277 | setlocal cursorline |
| 278 | |
| 279 | " underline |
| 280 | exe hi_ul |
| 281 | |
| 282 | " expected: |
| 283 | " 'abcd ' |
| 284 | " ^^^^ underline |
| 285 | " ^ 'Search' highlight with underline |
| 286 | " ^^^^^ underline |
| 287 | let attrs = ScreenAttrs(5, 10)[0] |
| 288 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 289 | call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9]) |
| 290 | call assert_notequal(attrs[0], attrs[4]) |
| 291 | call assert_notequal(attrs[4], attrs[5]) |
| 292 | call assert_notequal(attrs0[0], attrs[0]) |
| 293 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 294 | call Check_lcs_eol_attrs(attrs, 5, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 295 | |
| 296 | if IsColorable() |
| 297 | " bg-color |
| 298 | exe hi_bg |
| 299 | |
| 300 | " expected: |
| 301 | " 'abcd ' |
| 302 | " ^^^^ bg-color of 'CursorLine' |
| 303 | " ^ 'Search' highlight |
| 304 | " ^^^^^ bg-color of 'CursorLine' |
| 305 | let attrs = ScreenAttrs(5, 10)[0] |
| 306 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 307 | call assert_equal(repeat([attrs[5]], 5), attrs[5:9]) |
| 308 | call assert_equal(attrs0[4], attrs[4]) |
| 309 | call assert_notequal(attrs[0], attrs[4]) |
| 310 | call assert_notequal(attrs[4], attrs[5]) |
| 311 | call assert_notequal(attrs0[0], attrs[0]) |
| 312 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 313 | call Check_lcs_eol_attrs(attrs, 5, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 314 | endif |
| 315 | |
| 316 | setlocal nocursorline nowrap |
| 317 | normal! gg$ |
| 318 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 319 | setlocal cursorline |
| 320 | |
| 321 | " underline |
| 322 | exe hi_ul |
| 323 | |
| 324 | " expected: |
| 325 | " 'aaabcd ' |
| 326 | " ^^^^^^ underline |
| 327 | " ^ 'Search' highlight with underline |
| 328 | " ^^^ underline |
| 329 | let attrs = ScreenAttrs(1, 10)[0] |
| 330 | call assert_equal(repeat([attrs[0]], 6), attrs[0:5]) |
| 331 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 332 | call assert_notequal(attrs[0], attrs[6]) |
| 333 | call assert_notequal(attrs[6], attrs[7]) |
| 334 | call assert_notequal(attrs0[0], attrs[0]) |
| 335 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 336 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 337 | |
| 338 | if IsColorable() |
| 339 | " bg-color |
| 340 | exe hi_bg |
| 341 | |
| 342 | " expected: |
| 343 | " 'aaabcd ' |
| 344 | " ^^^^^^ bg-color of 'CursorLine' |
| 345 | " ^ 'Search' highlight |
| 346 | " ^^^ bg-color of 'CursorLine' |
| 347 | let attrs = ScreenAttrs(1, 10)[0] |
| 348 | call assert_equal(repeat([attrs[0]], 6), attrs[0:5]) |
| 349 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 350 | call assert_equal(attrs0[6], attrs[6]) |
| 351 | call assert_notequal(attrs[0], attrs[6]) |
| 352 | call assert_notequal(attrs[6], attrs[7]) |
| 353 | call assert_notequal(attrs0[0], attrs[0]) |
| 354 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 355 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 356 | endif |
| 357 | |
| 358 | call CloseWindow() |
| 359 | exe hiCursorLine |
| 360 | endfunc |
| 361 | |
| 362 | func Test_highlight_eol_with_cursorline_sign() |
| 363 | if !has('signs') |
| 364 | return |
| 365 | endif |
| 366 | |
| 367 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 368 | |
| 369 | call NewWindow('topleft 5', 10) |
| 370 | call setline(1, 'abcd') |
| 371 | call matchadd('Search', '\n') |
| 372 | |
| 373 | sign define Sign text=>> |
| 374 | exe 'sign place 1 line=1 name=Sign buffer=' . bufnr('') |
| 375 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 376 | setlocal cursorline |
| 377 | |
| 378 | " underline |
| 379 | exe hi_ul |
| 380 | |
| 381 | " expected: |
| 382 | " '>>abcd ' |
| 383 | " ^^ sign |
| 384 | " ^^^^ underline |
| 385 | " ^ 'Search' highlight with underline |
| 386 | " ^^^ underline |
| 387 | let attrs = ScreenAttrs(1, 10)[0] |
| 388 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 389 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 390 | call assert_notequal(attrs[2], attrs[6]) |
| 391 | call assert_notequal(attrs[6], attrs[7]) |
| 392 | call assert_notequal(attrs0[2], attrs[2]) |
| 393 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 394 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 395 | |
| 396 | if IsColorable() |
| 397 | " bg-color |
| 398 | exe hi_bg |
| 399 | |
| 400 | " expected: |
| 401 | " '>>abcd ' |
| 402 | " ^^ sign |
| 403 | " ^^^^ bg-color of 'CursorLine' |
| 404 | " ^ 'Search' highlight |
| 405 | " ^^^ bg-color of 'CursorLine' |
| 406 | let attrs = ScreenAttrs(1, 10)[0] |
| 407 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 408 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 409 | call assert_equal(attrs0[6], attrs[6]) |
| 410 | call assert_notequal(attrs[2], attrs[6]) |
| 411 | call assert_notequal(attrs[6], attrs[7]) |
| 412 | call assert_notequal(attrs0[2], attrs[2]) |
| 413 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 414 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 415 | endif |
| 416 | |
| 417 | sign unplace 1 |
| 418 | call CloseWindow() |
| 419 | exe hiCursorLine |
| 420 | endfunc |
| 421 | |
| 422 | func Test_highlight_eol_with_cursorline_breakindent() |
| 423 | if !has('linebreak') |
| 424 | return |
| 425 | endif |
| 426 | |
| 427 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 428 | |
| 429 | call NewWindow('topleft 5', 10) |
| 430 | setlocal breakindent breakindentopt=min:0,shift:1 showbreak=> |
| 431 | call setline(1, ' ' . repeat('a', 9) . 'bcd') |
| 432 | call matchadd('Search', '\n') |
| 433 | let attrs0 = ScreenAttrs(2, 10)[0] |
| 434 | setlocal cursorline |
| 435 | |
| 436 | " underline |
| 437 | exe hi_ul |
| 438 | |
| 439 | " expected: |
| 440 | " ' >bcd ' |
| 441 | " ^^^ breakindent and showbreak |
| 442 | " ^^^ underline |
| 443 | " ^ 'Search' highlight with underline |
| 444 | " ^^^ underline |
| 445 | let attrs = ScreenAttrs(2, 10)[0] |
| 446 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 447 | call assert_equal(repeat([attrs[3]], 3), attrs[3:5]) |
| 448 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 449 | call assert_equal(attrs0[0], attrs[0]) |
| 450 | call assert_notequal(attrs[0], attrs[2]) |
| 451 | call assert_notequal(attrs[2], attrs[3]) |
| 452 | call assert_notequal(attrs[3], attrs[6]) |
| 453 | call assert_notequal(attrs[6], attrs[7]) |
| 454 | call assert_notequal(attrs0[2], attrs[2]) |
| 455 | call assert_notequal(attrs0[3], attrs[3]) |
| 456 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 457 | call Check_lcs_eol_attrs(attrs, 2, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 458 | |
| 459 | if IsColorable() |
| 460 | " bg-color |
| 461 | exe hi_bg |
| 462 | |
| 463 | " expected: |
| 464 | " ' >bcd ' |
| 465 | " ^^^ breakindent and showbreak |
| 466 | " ^^^ bg-color of 'CursorLine' |
| 467 | " ^ 'Search' highlight |
| 468 | " ^^^ bg-color of 'CursorLine' |
| 469 | let attrs = ScreenAttrs(2, 10)[0] |
| 470 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 471 | call assert_equal(repeat([attrs[3]], 3), attrs[3:5]) |
| 472 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 473 | call assert_equal(attrs0[0], attrs[0]) |
| 474 | call assert_equal(attrs0[6], attrs[6]) |
| 475 | call assert_notequal(attrs[0], attrs[2]) |
| 476 | call assert_notequal(attrs[2], attrs[3]) |
| 477 | call assert_notequal(attrs[3], attrs[6]) |
| 478 | call assert_notequal(attrs[6], attrs[7]) |
| 479 | call assert_notequal(attrs0[2], attrs[2]) |
| 480 | call assert_notequal(attrs0[3], attrs[3]) |
| 481 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 482 | call Check_lcs_eol_attrs(attrs, 2, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 483 | endif |
| 484 | |
| 485 | call CloseWindow() |
| 486 | set showbreak= |
| 487 | exe hiCursorLine |
| 488 | endfunc |
| 489 | |
| 490 | func Test_highlight_eol_on_diff() |
| 491 | call setline(1, ['abcd', '']) |
| 492 | call matchadd('Search', '\n') |
| 493 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 494 | |
| 495 | diffthis |
| 496 | botright new |
| 497 | diffthis |
| 498 | |
| 499 | " expected: |
| 500 | " ' abcd ' |
| 501 | " ^^ sign |
| 502 | " ^^^^ ^^^ 'DiffAdd' highlight |
| 503 | " ^ 'Search' highlight |
| 504 | let attrs = ScreenAttrs(1, 10)[0] |
| 505 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 506 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 507 | call assert_equal(repeat([attrs[2]], 3), attrs[7:9]) |
| 508 | call assert_equal(attrs0[4], attrs[6]) |
| 509 | call assert_notequal(attrs[0], attrs[2]) |
| 510 | call assert_notequal(attrs[0], attrs[6]) |
| 511 | call assert_notequal(attrs[2], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 512 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 513 | |
| 514 | bwipe! |
| 515 | diffoff |
| 516 | endfunc |