Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 1 | " Tests for ":highlight" and highlighting. |
| 2 | |
| 3 | source view_util.vim |
Bram Moolenaar | c07ff5c | 2019-01-30 21:41:14 +0100 | [diff] [blame] | 4 | source screendump.vim |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 5 | source check.vim |
Bram Moolenaar | e8df010 | 2020-09-18 19:40:45 +0200 | [diff] [blame] | 6 | source script_util.vim |
Yegappan Lakshmanan | d1a8d65 | 2021-11-03 21:56:45 +0000 | [diff] [blame] | 7 | source vim9.vim |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 8 | |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 9 | func Test_highlight() |
| 10 | " basic test if ":highlight" doesn't crash |
| 11 | highlight |
| 12 | hi Search |
| 13 | |
| 14 | " test setting colors. |
| 15 | " test clearing one color and all doesn't generate error or warning |
| 16 | silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan |
| 17 | silent! hi Group2 term= cterm= |
| 18 | hi Group3 term=underline cterm=bold |
| 19 | |
| 20 | let res = split(execute("hi NewGroup"), "\n")[0] |
| 21 | " filter ctermfg and ctermbg, the numbers depend on the terminal |
| 22 | let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '') |
| 23 | let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '') |
| 24 | call assert_equal("NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3", |
| 25 | \ res) |
| 26 | call assert_equal("Group2 xxx cleared", |
| 27 | \ split(execute("hi Group2"), "\n")[0]) |
| 28 | call assert_equal("Group3 xxx term=underline cterm=bold", |
| 29 | \ split(execute("hi Group3"), "\n")[0]) |
| 30 | |
| 31 | hi clear NewGroup |
| 32 | call assert_equal("NewGroup xxx cleared", |
| 33 | \ split(execute("hi NewGroup"), "\n")[0]) |
| 34 | call assert_equal("Group2 xxx cleared", |
| 35 | \ split(execute("hi Group2"), "\n")[0]) |
| 36 | hi Group2 NONE |
| 37 | call assert_equal("Group2 xxx cleared", |
| 38 | \ split(execute("hi Group2"), "\n")[0]) |
| 39 | hi clear |
| 40 | call assert_equal("Group3 xxx cleared", |
| 41 | \ split(execute("hi Group3"), "\n")[0]) |
| 42 | call assert_fails("hi Crash term='asdf", "E475:") |
| 43 | endfunc |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 44 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 45 | func HighlightArgs(name) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 46 | return 'hi ' . substitute(split(execute('hi ' . a:name), '\n')[0], '\<xxx\>', '', '') |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 47 | endfunc |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 48 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 49 | func IsColorable() |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 50 | return has('gui_running') || str2nr(&t_Co) >= 8 |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 51 | endfunc |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 52 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 53 | func HiCursorLine() |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 54 | let hiCursorLine = HighlightArgs('CursorLine') |
| 55 | if has('gui_running') |
| 56 | let guibg = matchstr(hiCursorLine, 'guibg=\w\+') |
| 57 | let hi_ul = 'hi CursorLine gui=underline guibg=NONE' |
| 58 | let hi_bg = 'hi CursorLine gui=NONE ' . guibg |
| 59 | else |
| 60 | let hi_ul = 'hi CursorLine cterm=underline ctermbg=NONE' |
| 61 | let hi_bg = 'hi CursorLine cterm=NONE ctermbg=Gray' |
| 62 | endif |
| 63 | return [hiCursorLine, hi_ul, hi_bg] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 64 | endfunc |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 65 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 66 | func Check_lcs_eol_attrs(attrs, row, col) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 67 | let save_lcs = &lcs |
| 68 | set list |
| 69 | |
| 70 | call assert_equal(a:attrs, ScreenAttrs(a:row, a:col)[0]) |
| 71 | |
| 72 | set nolist |
| 73 | let &lcs = save_lcs |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 74 | endfunc |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 75 | |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 76 | func Test_highlight_eol_with_cursorline() |
| 77 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 78 | |
| 79 | call NewWindow('topleft 5', 20) |
| 80 | call setline(1, 'abcd') |
| 81 | call matchadd('Search', '\n') |
| 82 | |
| 83 | " expected: |
| 84 | " 'abcd ' |
| 85 | " ^^^^ ^^^^^ no highlight |
| 86 | " ^ 'Search' highlight |
| 87 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 88 | call assert_equal(repeat([attrs0[0]], 4), attrs0[0:3]) |
| 89 | call assert_equal(repeat([attrs0[0]], 5), attrs0[5:9]) |
| 90 | call assert_notequal(attrs0[0], attrs0[4]) |
| 91 | |
| 92 | setlocal cursorline |
| 93 | |
| 94 | " underline |
| 95 | exe hi_ul |
| 96 | |
| 97 | " expected: |
| 98 | " 'abcd ' |
| 99 | " ^^^^ underline |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 100 | " ^ 'Search' highlight with underline |
| 101 | " ^^^^^ underline |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 102 | let attrs = ScreenAttrs(1, 10)[0] |
| 103 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 104 | call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9]) |
| 105 | call assert_notequal(attrs[0], attrs[4]) |
| 106 | call assert_notequal(attrs[4], attrs[5]) |
| 107 | call assert_notequal(attrs0[0], attrs[0]) |
| 108 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 109 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 110 | |
| 111 | if IsColorable() |
| 112 | " bg-color |
| 113 | exe hi_bg |
| 114 | |
| 115 | " expected: |
| 116 | " 'abcd ' |
| 117 | " ^^^^ bg-color of 'CursorLine' |
| 118 | " ^ 'Search' highlight |
| 119 | " ^^^^^ bg-color of 'CursorLine' |
| 120 | let attrs = ScreenAttrs(1, 10)[0] |
| 121 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 122 | call assert_equal(repeat([attrs[5]], 5), attrs[5:9]) |
| 123 | call assert_equal(attrs0[4], attrs[4]) |
| 124 | call assert_notequal(attrs[0], attrs[4]) |
| 125 | call assert_notequal(attrs[4], attrs[5]) |
| 126 | call assert_notequal(attrs0[0], attrs[0]) |
| 127 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 128 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 129 | endif |
| 130 | |
| 131 | call CloseWindow() |
| 132 | exe hiCursorLine |
| 133 | endfunc |
| 134 | |
| 135 | func Test_highlight_eol_with_cursorline_vertsplit() |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 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() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 212 | CheckFeature rightleft |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 213 | |
| 214 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 215 | |
| 216 | call NewWindow('topleft 5', 10) |
| 217 | setlocal rightleft |
| 218 | call setline(1, 'abcd') |
| 219 | call matchadd('Search', '\n') |
| 220 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 221 | |
| 222 | setlocal cursorline |
| 223 | |
| 224 | " underline |
| 225 | exe hi_ul |
| 226 | |
| 227 | " expected: |
| 228 | " ' dcba' |
| 229 | " ^^^^ underline |
| 230 | " ^ 'Search' highlight with underline |
| 231 | " ^^^^^ underline |
| 232 | let attrs = ScreenAttrs(1, 10)[0] |
| 233 | call assert_equal(repeat([attrs[9]], 4), attrs[6:9]) |
| 234 | call assert_equal(repeat([attrs[4]], 5) + [attrs[5]], attrs[0:5]) |
| 235 | call assert_notequal(attrs[9], attrs[5]) |
| 236 | call assert_notequal(attrs[4], attrs[5]) |
| 237 | call assert_notequal(attrs0[9], attrs[9]) |
| 238 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 239 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 240 | |
| 241 | if IsColorable() |
| 242 | " bg-color |
| 243 | exe hi_bg |
| 244 | |
| 245 | " expected: |
| 246 | " ' dcba' |
| 247 | " ^^^^ bg-color of 'CursorLine' |
| 248 | " ^ 'Search' highlight |
| 249 | " ^^^^^ bg-color of 'CursorLine' |
| 250 | let attrs = ScreenAttrs(1, 10)[0] |
| 251 | call assert_equal(repeat([attrs[9]], 4), attrs[6:9]) |
| 252 | call assert_equal(repeat([attrs[4]], 5), attrs[0:4]) |
| 253 | call assert_equal(attrs0[5], attrs[5]) |
| 254 | call assert_notequal(attrs[9], attrs[5]) |
| 255 | call assert_notequal(attrs[5], attrs[4]) |
| 256 | call assert_notequal(attrs0[9], attrs[9]) |
| 257 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 258 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 259 | endif |
| 260 | |
| 261 | call CloseWindow() |
| 262 | exe hiCursorLine |
| 263 | endfunc |
| 264 | |
| 265 | func Test_highlight_eol_with_cursorline_linewrap() |
| 266 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 267 | |
| 268 | call NewWindow('topleft 5', 10) |
| 269 | call setline(1, [repeat('a', 51) . 'bcd', '']) |
| 270 | call matchadd('Search', '\n') |
| 271 | |
| 272 | setlocal wrap |
| 273 | normal! gg$ |
| 274 | let attrs0 = ScreenAttrs(5, 10)[0] |
| 275 | setlocal cursorline |
| 276 | |
| 277 | " underline |
| 278 | exe hi_ul |
| 279 | |
| 280 | " expected: |
| 281 | " 'abcd ' |
| 282 | " ^^^^ underline |
| 283 | " ^ 'Search' highlight with underline |
| 284 | " ^^^^^ underline |
| 285 | let attrs = ScreenAttrs(5, 10)[0] |
| 286 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 287 | call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9]) |
| 288 | call assert_notequal(attrs[0], attrs[4]) |
| 289 | call assert_notequal(attrs[4], attrs[5]) |
| 290 | call assert_notequal(attrs0[0], attrs[0]) |
| 291 | call assert_notequal(attrs0[4], attrs[4]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 292 | call Check_lcs_eol_attrs(attrs, 5, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 293 | |
| 294 | if IsColorable() |
| 295 | " bg-color |
| 296 | exe hi_bg |
| 297 | |
| 298 | " expected: |
| 299 | " 'abcd ' |
| 300 | " ^^^^ bg-color of 'CursorLine' |
| 301 | " ^ 'Search' highlight |
| 302 | " ^^^^^ bg-color of 'CursorLine' |
| 303 | let attrs = ScreenAttrs(5, 10)[0] |
| 304 | call assert_equal(repeat([attrs[0]], 4), attrs[0:3]) |
| 305 | call assert_equal(repeat([attrs[5]], 5), attrs[5:9]) |
| 306 | call assert_equal(attrs0[4], attrs[4]) |
| 307 | call assert_notequal(attrs[0], attrs[4]) |
| 308 | call assert_notequal(attrs[4], attrs[5]) |
| 309 | call assert_notequal(attrs0[0], attrs[0]) |
| 310 | call assert_notequal(attrs0[5], attrs[5]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 311 | call Check_lcs_eol_attrs(attrs, 5, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 312 | endif |
| 313 | |
| 314 | setlocal nocursorline nowrap |
| 315 | normal! gg$ |
| 316 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 317 | setlocal cursorline |
| 318 | |
| 319 | " underline |
| 320 | exe hi_ul |
| 321 | |
| 322 | " expected: |
| 323 | " 'aaabcd ' |
| 324 | " ^^^^^^ underline |
| 325 | " ^ 'Search' highlight with underline |
| 326 | " ^^^ underline |
| 327 | let attrs = ScreenAttrs(1, 10)[0] |
| 328 | call assert_equal(repeat([attrs[0]], 6), attrs[0:5]) |
| 329 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 330 | call assert_notequal(attrs[0], attrs[6]) |
| 331 | call assert_notequal(attrs[6], attrs[7]) |
| 332 | call assert_notequal(attrs0[0], attrs[0]) |
| 333 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 334 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 335 | |
| 336 | if IsColorable() |
| 337 | " bg-color |
| 338 | exe hi_bg |
| 339 | |
| 340 | " expected: |
| 341 | " 'aaabcd ' |
| 342 | " ^^^^^^ bg-color of 'CursorLine' |
| 343 | " ^ 'Search' highlight |
| 344 | " ^^^ bg-color of 'CursorLine' |
| 345 | let attrs = ScreenAttrs(1, 10)[0] |
| 346 | call assert_equal(repeat([attrs[0]], 6), attrs[0:5]) |
| 347 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 348 | call assert_equal(attrs0[6], attrs[6]) |
| 349 | call assert_notequal(attrs[0], attrs[6]) |
| 350 | call assert_notequal(attrs[6], attrs[7]) |
| 351 | call assert_notequal(attrs0[0], attrs[0]) |
| 352 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 353 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 354 | endif |
| 355 | |
| 356 | call CloseWindow() |
| 357 | exe hiCursorLine |
| 358 | endfunc |
| 359 | |
| 360 | func Test_highlight_eol_with_cursorline_sign() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 361 | CheckFeature signs |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 362 | |
| 363 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 364 | |
| 365 | call NewWindow('topleft 5', 10) |
| 366 | call setline(1, 'abcd') |
| 367 | call matchadd('Search', '\n') |
| 368 | |
| 369 | sign define Sign text=>> |
| 370 | exe 'sign place 1 line=1 name=Sign buffer=' . bufnr('') |
| 371 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 372 | setlocal cursorline |
| 373 | |
| 374 | " underline |
| 375 | exe hi_ul |
| 376 | |
| 377 | " expected: |
| 378 | " '>>abcd ' |
| 379 | " ^^ sign |
| 380 | " ^^^^ underline |
| 381 | " ^ 'Search' highlight with underline |
| 382 | " ^^^ underline |
| 383 | let attrs = ScreenAttrs(1, 10)[0] |
| 384 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 385 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 386 | call assert_notequal(attrs[2], attrs[6]) |
| 387 | call assert_notequal(attrs[6], attrs[7]) |
| 388 | call assert_notequal(attrs0[2], attrs[2]) |
| 389 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 390 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 391 | |
| 392 | if IsColorable() |
| 393 | " bg-color |
| 394 | exe hi_bg |
| 395 | |
| 396 | " expected: |
| 397 | " '>>abcd ' |
| 398 | " ^^ sign |
| 399 | " ^^^^ bg-color of 'CursorLine' |
| 400 | " ^ 'Search' highlight |
| 401 | " ^^^ bg-color of 'CursorLine' |
| 402 | let attrs = ScreenAttrs(1, 10)[0] |
| 403 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 404 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 405 | call assert_equal(attrs0[6], attrs[6]) |
| 406 | call assert_notequal(attrs[2], attrs[6]) |
| 407 | call assert_notequal(attrs[6], attrs[7]) |
| 408 | call assert_notequal(attrs0[2], attrs[2]) |
| 409 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 410 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 411 | endif |
| 412 | |
| 413 | sign unplace 1 |
| 414 | call CloseWindow() |
| 415 | exe hiCursorLine |
| 416 | endfunc |
| 417 | |
| 418 | func Test_highlight_eol_with_cursorline_breakindent() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 419 | CheckFeature linebreak |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 420 | |
| 421 | let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine() |
| 422 | |
| 423 | call NewWindow('topleft 5', 10) |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 424 | set showbreak=xxx |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 425 | setlocal breakindent breakindentopt=min:0,shift:1 showbreak=> |
| 426 | call setline(1, ' ' . repeat('a', 9) . 'bcd') |
| 427 | call matchadd('Search', '\n') |
| 428 | let attrs0 = ScreenAttrs(2, 10)[0] |
| 429 | setlocal cursorline |
| 430 | |
| 431 | " underline |
| 432 | exe hi_ul |
| 433 | |
| 434 | " expected: |
| 435 | " ' >bcd ' |
| 436 | " ^^^ breakindent and showbreak |
| 437 | " ^^^ underline |
| 438 | " ^ 'Search' highlight with underline |
| 439 | " ^^^ underline |
| 440 | let attrs = ScreenAttrs(2, 10)[0] |
| 441 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 442 | call assert_equal(repeat([attrs[3]], 3), attrs[3:5]) |
| 443 | call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9]) |
| 444 | call assert_equal(attrs0[0], attrs[0]) |
| 445 | call assert_notequal(attrs[0], attrs[2]) |
| 446 | call assert_notequal(attrs[2], attrs[3]) |
| 447 | call assert_notequal(attrs[3], attrs[6]) |
| 448 | call assert_notequal(attrs[6], attrs[7]) |
| 449 | call assert_notequal(attrs0[2], attrs[2]) |
| 450 | call assert_notequal(attrs0[3], attrs[3]) |
| 451 | call assert_notequal(attrs0[6], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 452 | call Check_lcs_eol_attrs(attrs, 2, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 453 | |
| 454 | if IsColorable() |
| 455 | " bg-color |
| 456 | exe hi_bg |
| 457 | |
| 458 | " expected: |
| 459 | " ' >bcd ' |
| 460 | " ^^^ breakindent and showbreak |
| 461 | " ^^^ bg-color of 'CursorLine' |
| 462 | " ^ 'Search' highlight |
| 463 | " ^^^ bg-color of 'CursorLine' |
| 464 | let attrs = ScreenAttrs(2, 10)[0] |
| 465 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 466 | call assert_equal(repeat([attrs[3]], 3), attrs[3:5]) |
| 467 | call assert_equal(repeat([attrs[7]], 3), attrs[7:9]) |
| 468 | call assert_equal(attrs0[0], attrs[0]) |
| 469 | call assert_equal(attrs0[6], attrs[6]) |
| 470 | call assert_notequal(attrs[0], attrs[2]) |
| 471 | call assert_notequal(attrs[2], attrs[3]) |
| 472 | call assert_notequal(attrs[3], attrs[6]) |
| 473 | call assert_notequal(attrs[6], attrs[7]) |
| 474 | call assert_notequal(attrs0[2], attrs[2]) |
| 475 | call assert_notequal(attrs0[3], attrs[3]) |
| 476 | call assert_notequal(attrs0[7], attrs[7]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 477 | call Check_lcs_eol_attrs(attrs, 2, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 478 | endif |
| 479 | |
| 480 | call CloseWindow() |
| 481 | set showbreak= |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 482 | setlocal showbreak= |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 483 | exe hiCursorLine |
| 484 | endfunc |
| 485 | |
| 486 | func Test_highlight_eol_on_diff() |
| 487 | call setline(1, ['abcd', '']) |
| 488 | call matchadd('Search', '\n') |
| 489 | let attrs0 = ScreenAttrs(1, 10)[0] |
| 490 | |
| 491 | diffthis |
| 492 | botright new |
| 493 | diffthis |
| 494 | |
| 495 | " expected: |
| 496 | " ' abcd ' |
| 497 | " ^^ sign |
| 498 | " ^^^^ ^^^ 'DiffAdd' highlight |
| 499 | " ^ 'Search' highlight |
| 500 | let attrs = ScreenAttrs(1, 10)[0] |
| 501 | call assert_equal(repeat([attrs[0]], 2), attrs[0:1]) |
| 502 | call assert_equal(repeat([attrs[2]], 4), attrs[2:5]) |
| 503 | call assert_equal(repeat([attrs[2]], 3), attrs[7:9]) |
| 504 | call assert_equal(attrs0[4], attrs[6]) |
| 505 | call assert_notequal(attrs[0], attrs[2]) |
| 506 | call assert_notequal(attrs[0], attrs[6]) |
| 507 | call assert_notequal(attrs[2], attrs[6]) |
Bram Moolenaar | 5ece3e3 | 2017-10-01 14:35:02 +0200 | [diff] [blame] | 508 | call Check_lcs_eol_attrs(attrs, 1, 10) |
Bram Moolenaar | 0aa398f | 2017-09-30 21:23:55 +0200 | [diff] [blame] | 509 | |
| 510 | bwipe! |
| 511 | diffoff |
| 512 | endfunc |
Bram Moolenaar | f708ac5 | 2018-03-12 21:48:32 +0100 | [diff] [blame] | 513 | |
| 514 | func Test_termguicolors() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 515 | CheckOption termguicolors |
Bram Moolenaar | 310c32e | 2019-11-29 23:15:25 +0100 | [diff] [blame] | 516 | if has('vtp') && !has('vcon') && !has('gui_running') |
Bram Moolenaar | ff1e879 | 2018-03-12 22:16:37 +0100 | [diff] [blame] | 517 | " Win32: 'guicolors' doesn't work without virtual console. |
| 518 | call assert_fails('set termguicolors', 'E954:') |
| 519 | return |
| 520 | endif |
Bram Moolenaar | f708ac5 | 2018-03-12 21:48:32 +0100 | [diff] [blame] | 521 | |
| 522 | " Basic test that setting 'termguicolors' works with one color. |
| 523 | set termguicolors |
| 524 | redraw |
| 525 | set t_Co=1 |
| 526 | redraw |
| 527 | set t_Co=0 |
| 528 | redraw |
| 529 | endfunc |
Bram Moolenaar | c07ff5c | 2019-01-30 21:41:14 +0100 | [diff] [blame] | 530 | |
| 531 | func Test_cursorline_after_yank() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 532 | CheckScreendump |
Bram Moolenaar | c07ff5c | 2019-01-30 21:41:14 +0100 | [diff] [blame] | 533 | |
| 534 | call writefile([ |
| 535 | \ 'set cul rnu', |
| 536 | \ 'call setline(1, ["","1","2","3",""])', |
| 537 | \ ], 'Xtest_cursorline_yank') |
| 538 | let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 539 | call TermWait(buf) |
Bram Moolenaar | c07ff5c | 2019-01-30 21:41:14 +0100 | [diff] [blame] | 540 | call term_sendkeys(buf, "Gy3k") |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 541 | call TermWait(buf) |
Bram Moolenaar | c07ff5c | 2019-01-30 21:41:14 +0100 | [diff] [blame] | 542 | call term_sendkeys(buf, "jj") |
| 543 | |
| 544 | call VerifyScreenDump(buf, 'Test_cursorline_yank_01', {}) |
| 545 | |
| 546 | " clean up |
| 547 | call StopVimInTerminal(buf) |
| 548 | call delete('Xtest_cursorline_yank') |
| 549 | endfunc |
Bram Moolenaar | 8156ed3 | 2019-03-09 11:46:15 +0100 | [diff] [blame] | 550 | |
Bram Moolenaar | fca068b | 2019-09-08 14:07:47 +0200 | [diff] [blame] | 551 | " test for issue #4862 |
| 552 | func Test_put_before_cursorline() |
| 553 | new |
| 554 | only! |
| 555 | call setline(1, 'A') |
| 556 | redraw |
| 557 | let std_attr = screenattr(1, 1) |
| 558 | set cursorline |
| 559 | redraw |
| 560 | let cul_attr = screenattr(1, 1) |
| 561 | normal yyP |
| 562 | redraw |
| 563 | " Line 1 has cursor so it should be highlighted with CursorLine. |
| 564 | call assert_equal(cul_attr, screenattr(1, 1)) |
| 565 | " And CursorLine highlighting from the second line should be gone. |
| 566 | call assert_equal(std_attr, screenattr(2, 1)) |
| 567 | set nocursorline |
| 568 | bwipe! |
| 569 | endfunc |
| 570 | |
Bram Moolenaar | 8156ed3 | 2019-03-09 11:46:15 +0100 | [diff] [blame] | 571 | func Test_cursorline_with_visualmode() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 572 | CheckScreendump |
Bram Moolenaar | 8156ed3 | 2019-03-09 11:46:15 +0100 | [diff] [blame] | 573 | |
| 574 | call writefile([ |
| 575 | \ 'set cul', |
| 576 | \ 'call setline(1, repeat(["abc"], 50))', |
| 577 | \ ], 'Xtest_cursorline_with_visualmode') |
| 578 | let buf = RunVimInTerminal('-S Xtest_cursorline_with_visualmode', {'rows': 12}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 579 | call TermWait(buf) |
Bram Moolenaar | 8156ed3 | 2019-03-09 11:46:15 +0100 | [diff] [blame] | 580 | call term_sendkeys(buf, "V\<C-f>kkkjk") |
| 581 | |
| 582 | call VerifyScreenDump(buf, 'Test_cursorline_with_visualmode_01', {}) |
| 583 | |
| 584 | " clean up |
| 585 | call StopVimInTerminal(buf) |
| 586 | call delete('Xtest_cursorline_with_visualmode') |
| 587 | endfunc |
Bram Moolenaar | f90b6e0 | 2019-05-09 19:26:38 +0200 | [diff] [blame] | 588 | |
Bram Moolenaar | 193ffd1 | 2019-05-25 22:57:30 +0200 | [diff] [blame] | 589 | func Test_wincolor() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 590 | CheckScreendump |
Bram Moolenaar | 3180fe6 | 2020-02-02 13:47:06 +0100 | [diff] [blame] | 591 | " make sure the width is enough for the test |
| 592 | set columns=80 |
Bram Moolenaar | 193ffd1 | 2019-05-25 22:57:30 +0200 | [diff] [blame] | 593 | |
Bram Moolenaar | e7eb927 | 2019-06-24 00:58:07 +0200 | [diff] [blame] | 594 | let lines =<< trim END |
| 595 | set cursorline cursorcolumn rnu |
Bram Moolenaar | 053f712 | 2019-09-23 22:17:15 +0200 | [diff] [blame] | 596 | call setline(1, ["","1111111111","22222222222","3 here 3","","the cat is out of the bag"]) |
Bram Moolenaar | e7eb927 | 2019-06-24 00:58:07 +0200 | [diff] [blame] | 597 | set wincolor=Pmenu |
Bram Moolenaar | 053f712 | 2019-09-23 22:17:15 +0200 | [diff] [blame] | 598 | hi CatLine guifg=green ctermfg=green |
| 599 | hi Reverse gui=reverse cterm=reverse |
| 600 | syn match CatLine /^the.*/ |
| 601 | call prop_type_add("foo", {"highlight": "Reverse", "combine": 1}) |
| 602 | call prop_add(6, 12, {"type": "foo", "end_col": 15}) |
Bram Moolenaar | e7eb927 | 2019-06-24 00:58:07 +0200 | [diff] [blame] | 603 | /here |
| 604 | END |
| 605 | call writefile(lines, 'Xtest_wincolor') |
Bram Moolenaar | 193ffd1 | 2019-05-25 22:57:30 +0200 | [diff] [blame] | 606 | let buf = RunVimInTerminal('-S Xtest_wincolor', {'rows': 8}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 607 | call TermWait(buf) |
Bram Moolenaar | 193ffd1 | 2019-05-25 22:57:30 +0200 | [diff] [blame] | 608 | call term_sendkeys(buf, "2G5lvj") |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 609 | call TermWait(buf) |
Bram Moolenaar | 193ffd1 | 2019-05-25 22:57:30 +0200 | [diff] [blame] | 610 | |
| 611 | call VerifyScreenDump(buf, 'Test_wincolor_01', {}) |
| 612 | |
| 613 | " clean up |
| 614 | call term_sendkeys(buf, "\<Esc>") |
| 615 | call StopVimInTerminal(buf) |
| 616 | call delete('Xtest_wincolor') |
| 617 | endfunc |
| 618 | |
Bram Moolenaar | 42e931b | 2019-12-04 19:08:50 +0100 | [diff] [blame] | 619 | func Test_wincolor_listchars() |
| 620 | CheckScreendump |
Bram Moolenaar | 705724e | 2020-01-31 21:13:42 +0100 | [diff] [blame] | 621 | CheckFeature conceal |
Bram Moolenaar | 42e931b | 2019-12-04 19:08:50 +0100 | [diff] [blame] | 622 | |
| 623 | let lines =<< trim END |
| 624 | call setline(1, ["one","\t\tsome random text enough long to show 'extends' and 'precedes' includingnbsps, preceding tabs and trailing spaces ","three"]) |
| 625 | set wincolor=Todo |
| 626 | set nowrap cole=1 cocu+=n |
| 627 | set list lcs=eol:$,tab:>-,space:.,trail:_,extends:>,precedes:<,conceal:*,nbsp:# |
| 628 | call matchadd('Conceal', 'text') |
| 629 | normal 2G5zl |
| 630 | END |
| 631 | call writefile(lines, 'Xtest_wincolorlcs') |
| 632 | let buf = RunVimInTerminal('-S Xtest_wincolorlcs', {'rows': 8}) |
| 633 | |
| 634 | call VerifyScreenDump(buf, 'Test_wincolor_lcs', {}) |
| 635 | |
| 636 | " clean up |
| 637 | call term_sendkeys(buf, "\<Esc>") |
| 638 | call StopVimInTerminal(buf) |
| 639 | call delete('Xtest_wincolorlcs') |
| 640 | endfunc |
| 641 | |
Bram Moolenaar | 010ee96 | 2019-09-25 20:37:36 +0200 | [diff] [blame] | 642 | func Test_colorcolumn() |
| 643 | CheckScreendump |
| 644 | |
| 645 | " check that setting 'colorcolumn' when entering a buffer works |
| 646 | let lines =<< trim END |
| 647 | split |
| 648 | edit X |
| 649 | call setline(1, ["1111111111","22222222222","3333333333"]) |
| 650 | set nomodified |
| 651 | set colorcolumn=3,9 |
| 652 | set number cursorline cursorlineopt=number |
| 653 | wincmd w |
| 654 | buf X |
| 655 | END |
| 656 | call writefile(lines, 'Xtest_colorcolumn') |
| 657 | let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10}) |
| 658 | call term_sendkeys(buf, ":\<CR>") |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 659 | call TermWait(buf) |
Bram Moolenaar | 010ee96 | 2019-09-25 20:37:36 +0200 | [diff] [blame] | 660 | call VerifyScreenDump(buf, 'Test_colorcolumn_1', {}) |
| 661 | |
| 662 | " clean up |
| 663 | call StopVimInTerminal(buf) |
| 664 | call delete('Xtest_colorcolumn') |
| 665 | endfunc |
| 666 | |
Bram Moolenaar | ad5e563 | 2020-09-15 20:52:26 +0200 | [diff] [blame] | 667 | func Test_colorcolumn_bri() |
| 668 | CheckScreendump |
| 669 | |
| 670 | " check 'colorcolumn' when 'breakindent' is set |
| 671 | let lines =<< trim END |
| 672 | call setline(1, 'The quick brown fox jumped over the lazy dogs') |
| 673 | END |
| 674 | call writefile(lines, 'Xtest_colorcolumn_bri') |
| 675 | let buf = RunVimInTerminal('-S Xtest_colorcolumn_bri', {'rows': 10,'columns': 40}) |
| 676 | call term_sendkeys(buf, ":set co=40 linebreak bri briopt=shift:2 cc=40,41,43\<CR>") |
| 677 | call TermWait(buf) |
| 678 | call VerifyScreenDump(buf, 'Test_colorcolumn_2', {}) |
| 679 | |
| 680 | " clean up |
| 681 | call StopVimInTerminal(buf) |
| 682 | call delete('Xtest_colorcolumn_bri') |
| 683 | endfunc |
| 684 | |
| 685 | func Test_colorcolumn_sbr() |
| 686 | CheckScreendump |
| 687 | |
| 688 | " check 'colorcolumn' when 'showbreak' is set |
| 689 | let lines =<< trim END |
| 690 | call setline(1, 'The quick brown fox jumped over the lazy dogs') |
| 691 | END |
| 692 | call writefile(lines, 'Xtest_colorcolumn_srb') |
| 693 | let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40}) |
| 694 | call term_sendkeys(buf, ":set co=40 showbreak=+++>\\ cc=40,41,43\<CR>") |
| 695 | call TermWait(buf) |
| 696 | call VerifyScreenDump(buf, 'Test_colorcolumn_3', {}) |
| 697 | |
| 698 | " clean up |
| 699 | call StopVimInTerminal(buf) |
| 700 | call delete('Xtest_colorcolumn_srb') |
| 701 | endfunc |
| 702 | |
Bram Moolenaar | 6b528fa | 2019-05-09 20:07:33 +0200 | [diff] [blame] | 703 | " This test must come before the Test_cursorline test, as it appears this |
| 704 | " defines the Normal highlighting group anyway. |
Bram Moolenaar | f90b6e0 | 2019-05-09 19:26:38 +0200 | [diff] [blame] | 705 | func Test_1_highlight_Normalgroup_exists() |
Bram Moolenaar | 435f9f0 | 2019-07-03 21:40:16 +0200 | [diff] [blame] | 706 | let hlNormal = HighlightArgs('Normal') |
| 707 | if !has('gui_running') |
Bram Moolenaar | 6b528fa | 2019-05-09 20:07:33 +0200 | [diff] [blame] | 708 | call assert_match('hi Normal\s*clear', hlNormal) |
Bram Moolenaar | 435f9f0 | 2019-07-03 21:40:16 +0200 | [diff] [blame] | 709 | elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') |
| 710 | " expect is DEFAULT_FONT of gui_gtk_x11.c |
| 711 | call assert_match('hi Normal\s*font=Monospace 10', hlNormal) |
| 712 | elseif has('gui_motif') || has('gui_athena') |
| 713 | " expect is DEFAULT_FONT of gui_x11.c |
| 714 | call assert_match('hi Normal\s*font=7x13', hlNormal) |
| 715 | elseif has('win32') |
| 716 | " expect any font |
| 717 | call assert_match('hi Normal\s*font=.*', hlNormal) |
Bram Moolenaar | 6b528fa | 2019-05-09 20:07:33 +0200 | [diff] [blame] | 718 | endif |
Bram Moolenaar | f90b6e0 | 2019-05-09 19:26:38 +0200 | [diff] [blame] | 719 | endfunc |
Bram Moolenaar | 548be7f | 2019-06-29 03:42:42 +0200 | [diff] [blame] | 720 | |
Bram Moolenaar | 3180fe6 | 2020-02-02 13:47:06 +0100 | [diff] [blame] | 721 | " Do this test last, sometimes restoring the columns doesn't work |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 722 | func Test_z_no_space_before_xxx() |
Bram Moolenaar | 548be7f | 2019-06-29 03:42:42 +0200 | [diff] [blame] | 723 | let l:org_columns = &columns |
| 724 | set columns=17 |
| 725 | let l:hi_StatusLineTermNC = join(split(execute('hi StatusLineTermNC'))) |
| 726 | call assert_match('StatusLineTermNC xxx', l:hi_StatusLineTermNC) |
| 727 | let &columns = l:org_columns |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 728 | endfunc |
| 729 | |
| 730 | " Test for :highlight command errors |
| 731 | func Test_highlight_cmd_errors() |
| 732 | if has('gui_running') |
| 733 | " This test doesn't fail in the MS-Windows console version. |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 734 | call assert_fails('hi Xcomment ctermbg=fg', 'E419:') |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 735 | call assert_fails('hi Xcomment ctermfg=bg', 'E420:') |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 736 | call assert_fails('hi Xcomment ctermfg=ul', 'E453:') |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 737 | endif |
| 738 | |
| 739 | " Try using a very long terminal code. Define a dummy terminal code for this |
| 740 | " test. |
| 741 | let &t_fo = "\<Esc>1;" |
| 742 | let c = repeat("t_fo,", 100) . "t_fo" |
| 743 | call assert_fails('exe "hi Xgroup1 start=" . c', 'E422:') |
| 744 | let &t_fo = "" |
| 745 | endfunc |
| 746 | |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 747 | " Test for 'highlight' option |
| 748 | func Test_highlight_opt() |
| 749 | let save_hl = &highlight |
| 750 | call assert_fails('set highlight=j:b', 'E474:') |
| 751 | set highlight=f\ r |
| 752 | call assert_equal('f r', &highlight) |
| 753 | set highlight=fb |
| 754 | call assert_equal('fb', &highlight) |
| 755 | set highlight=fi |
| 756 | call assert_equal('fi', &highlight) |
| 757 | set highlight=f- |
| 758 | call assert_equal('f-', &highlight) |
| 759 | set highlight=fr |
| 760 | call assert_equal('fr', &highlight) |
| 761 | set highlight=fs |
| 762 | call assert_equal('fs', &highlight) |
| 763 | set highlight=fu |
| 764 | call assert_equal('fu', &highlight) |
| 765 | set highlight=fc |
| 766 | call assert_equal('fc', &highlight) |
| 767 | set highlight=ft |
| 768 | call assert_equal('ft', &highlight) |
| 769 | call assert_fails('set highlight=fr:Search', 'E474:') |
| 770 | set highlight=f:$# |
| 771 | call assert_match('W18:', v:statusmsg) |
| 772 | let &highlight = save_hl |
| 773 | endfunc |
| 774 | |
| 775 | " Test for User group highlighting used in the statusline |
| 776 | func Test_highlight_User() |
| 777 | CheckNotGui |
| 778 | hi User1 ctermfg=12 |
| 779 | redraw! |
| 780 | call assert_equal('12', synIDattr(synIDtrans(hlID('User1')), 'fg')) |
| 781 | hi clear |
| 782 | endfunc |
| 783 | |
| 784 | " Test for using RGB color values in a highlight group |
Bram Moolenaar | 09fbedc | 2021-01-19 17:22:58 +0100 | [diff] [blame] | 785 | func Test_xxlast_highlight_RGB_color() |
| 786 | CheckCanRunGui |
| 787 | gui -f |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 788 | hi MySearch guifg=#110000 guibg=#001100 guisp=#000011 |
| 789 | call assert_equal('#110000', synIDattr(synIDtrans(hlID('MySearch')), 'fg#')) |
| 790 | call assert_equal('#001100', synIDattr(synIDtrans(hlID('MySearch')), 'bg#')) |
| 791 | call assert_equal('#000011', synIDattr(synIDtrans(hlID('MySearch')), 'sp#')) |
| 792 | hi clear |
| 793 | endfunc |
| 794 | |
Bram Moolenaar | de8f0f4 | 2020-06-30 18:45:43 +0200 | [diff] [blame] | 795 | " Test for using default highlighting group |
| 796 | func Test_highlight_default() |
| 797 | highlight MySearch ctermfg=7 |
| 798 | highlight default MySearch ctermfg=5 |
| 799 | let hlSearch = HighlightArgs('MySearch') |
| 800 | call assert_match('ctermfg=7', hlSearch) |
| 801 | |
| 802 | highlight default QFName ctermfg=3 |
| 803 | call assert_match('ctermfg=3', HighlightArgs('QFName')) |
| 804 | hi clear |
| 805 | endfunc |
| 806 | |
| 807 | " Test for 'ctermul in a highlight group |
| 808 | func Test_highlight_ctermul() |
| 809 | CheckNotGui |
| 810 | call assert_notmatch('ctermul=', HighlightArgs('Normal')) |
| 811 | highlight Normal ctermul=3 |
| 812 | call assert_match('ctermul=3', HighlightArgs('Normal')) |
Bram Moolenaar | 391c362 | 2020-09-29 20:59:17 +0200 | [diff] [blame] | 813 | call assert_equal('3', synIDattr(synIDtrans(hlID('Normal')), 'ul')) |
Bram Moolenaar | de8f0f4 | 2020-06-30 18:45:43 +0200 | [diff] [blame] | 814 | highlight Normal ctermul=NONE |
| 815 | endfunc |
| 816 | |
| 817 | " Test for specifying 'start' and 'stop' in a highlight group |
| 818 | func Test_highlight_start_stop() |
| 819 | hi HlGrp1 start=<Esc>[27h;<Esc>[<Space>r; |
| 820 | call assert_match("start=^[[27h;^[[ r;", HighlightArgs('HlGrp1')) |
| 821 | hi HlGrp1 start=NONE |
| 822 | call assert_notmatch("start=", HighlightArgs('HlGrp1')) |
| 823 | hi HlGrp2 stop=<Esc>[27h;<Esc>[<Space>r; |
| 824 | call assert_match("stop=^[[27h;^[[ r;", HighlightArgs('HlGrp2')) |
| 825 | hi HlGrp2 stop=NONE |
| 826 | call assert_notmatch("stop=", HighlightArgs('HlGrp2')) |
| 827 | hi clear |
| 828 | endfunc |
| 829 | |
| 830 | " Test for setting various 'term' attributes |
| 831 | func Test_highlight_term_attr() |
| 832 | hi HlGrp3 term=bold,underline,undercurl,strikethrough,reverse,italic,standout |
| 833 | call assert_equal('hi HlGrp3 term=bold,standout,underline,undercurl,italic,reverse,strikethrough', HighlightArgs('HlGrp3')) |
| 834 | hi HlGrp3 term=NONE |
| 835 | call assert_equal('hi HlGrp3 cleared', HighlightArgs('HlGrp3')) |
| 836 | hi clear |
| 837 | endfunc |
| 838 | |
Bram Moolenaar | 213da55 | 2020-09-17 19:59:26 +0200 | [diff] [blame] | 839 | func Test_highlight_clear_restores_links() |
| 840 | let aaa_id = hlID('aaa') |
| 841 | call assert_equal(aaa_id, 0) |
| 842 | |
| 843 | " create default link aaa --> bbb |
| 844 | hi def link aaa bbb |
| 845 | let id_aaa = hlID('aaa') |
| 846 | let hl_aaa_bbb = HighlightArgs('aaa') |
| 847 | |
| 848 | " try to redefine default link aaa --> ccc; check aaa --> bbb |
| 849 | hi def link aaa ccc |
| 850 | call assert_equal(HighlightArgs('aaa'), hl_aaa_bbb) |
| 851 | |
| 852 | " clear aaa; check aaa --> bbb |
| 853 | hi clear aaa |
| 854 | call assert_equal(HighlightArgs('aaa'), hl_aaa_bbb) |
| 855 | |
| 856 | " link aaa --> ccc; clear aaa; check aaa --> bbb |
| 857 | hi link aaa ccc |
| 858 | let id_ccc = hlID('ccc') |
| 859 | call assert_equal(synIDtrans(id_aaa), id_ccc) |
| 860 | hi clear aaa |
| 861 | call assert_equal(HighlightArgs('aaa'), hl_aaa_bbb) |
| 862 | |
| 863 | " forcibly set default link aaa --> ddd |
| 864 | hi! def link aaa ddd |
| 865 | let id_ddd = hlID('ddd') |
| 866 | let hl_aaa_ddd = HighlightArgs('aaa') |
| 867 | call assert_equal(synIDtrans(id_aaa), id_ddd) |
| 868 | |
| 869 | " link aaa --> eee; clear aaa; check aaa --> ddd |
| 870 | hi link aaa eee |
| 871 | let eee_id = hlID('eee') |
| 872 | call assert_equal(synIDtrans(id_aaa), eee_id) |
| 873 | hi clear aaa |
| 874 | call assert_equal(HighlightArgs('aaa'), hl_aaa_ddd) |
| 875 | endfunc |
| 876 | |
Bram Moolenaar | e8df010 | 2020-09-18 19:40:45 +0200 | [diff] [blame] | 877 | func Test_highlight_clear_restores_context() |
| 878 | func FuncContextDefault() |
| 879 | hi def link Context ContextDefault |
| 880 | endfun |
| 881 | |
| 882 | func FuncContextRelink() |
| 883 | " Dummy line |
| 884 | hi link Context ContextRelink |
| 885 | endfunc |
| 886 | |
| 887 | let scriptContextDefault = MakeScript("FuncContextDefault") |
| 888 | let scriptContextRelink = MakeScript("FuncContextRelink") |
| 889 | let patContextDefault = fnamemodify(scriptContextDefault, ':t') .. ' line 1' |
| 890 | let patContextRelink = fnamemodify(scriptContextRelink, ':t') .. ' line 2' |
| 891 | |
Bram Moolenaar | 2bbada8 | 2020-09-18 21:55:26 +0200 | [diff] [blame] | 892 | exec 'source ' .. scriptContextDefault |
Bram Moolenaar | e8df010 | 2020-09-18 19:40:45 +0200 | [diff] [blame] | 893 | let hlContextDefault = execute("verbose hi Context") |
| 894 | call assert_match(patContextDefault, hlContextDefault) |
| 895 | |
Bram Moolenaar | 2bbada8 | 2020-09-18 21:55:26 +0200 | [diff] [blame] | 896 | exec 'source ' .. scriptContextRelink |
Bram Moolenaar | e8df010 | 2020-09-18 19:40:45 +0200 | [diff] [blame] | 897 | let hlContextRelink = execute("verbose hi Context") |
| 898 | call assert_match(patContextRelink, hlContextRelink) |
| 899 | |
| 900 | hi clear |
| 901 | let hlContextAfterClear = execute("verbose hi Context") |
| 902 | call assert_match(patContextDefault, hlContextAfterClear) |
| 903 | |
| 904 | delfunc FuncContextDefault |
| 905 | delfunc FuncContextRelink |
| 906 | call delete(scriptContextDefault) |
| 907 | call delete(scriptContextRelink) |
| 908 | endfunc |
| 909 | |
Bram Moolenaar | 213da55 | 2020-09-17 19:59:26 +0200 | [diff] [blame] | 910 | func Test_highlight_default_colorscheme_restores_links() |
| 911 | hi link TestLink Identifier |
| 912 | hi TestHi ctermbg=red |
Bram Moolenaar | 05eb5b9 | 2020-09-16 15:43:21 +0200 | [diff] [blame] | 913 | |
| 914 | let hlTestLinkPre = HighlightArgs('TestLink') |
| 915 | let hlTestHiPre = HighlightArgs('TestHi') |
| 916 | |
| 917 | " Test colorscheme |
| 918 | hi clear |
| 919 | if exists('syntax_on') |
| 920 | syntax reset |
| 921 | endif |
| 922 | let g:colors_name = 'test' |
Bram Moolenaar | 213da55 | 2020-09-17 19:59:26 +0200 | [diff] [blame] | 923 | hi link TestLink ErrorMsg |
| 924 | hi TestHi ctermbg=green |
Bram Moolenaar | 05eb5b9 | 2020-09-16 15:43:21 +0200 | [diff] [blame] | 925 | |
| 926 | " Restore default highlighting |
| 927 | colorscheme default |
Bram Moolenaar | 05eb5b9 | 2020-09-16 15:43:21 +0200 | [diff] [blame] | 928 | " 'default' should work no matter if highlight group was cleared |
| 929 | hi def link TestLink Identifier |
| 930 | hi def TestHi ctermbg=red |
Bram Moolenaar | 05eb5b9 | 2020-09-16 15:43:21 +0200 | [diff] [blame] | 931 | let hlTestLinkPost = HighlightArgs('TestLink') |
| 932 | let hlTestHiPost = HighlightArgs('TestHi') |
Bram Moolenaar | 05eb5b9 | 2020-09-16 15:43:21 +0200 | [diff] [blame] | 933 | call assert_equal(hlTestLinkPre, hlTestLinkPost) |
| 934 | call assert_equal(hlTestHiPre, hlTestHiPost) |
| 935 | hi clear |
| 936 | endfunc |
| 937 | |
Drew Vogel | e30d102 | 2021-10-24 20:35:07 +0100 | [diff] [blame] | 938 | func Test_colornames_assignment_and_lookup() |
| 939 | " Ensure highlight command can find custom color. |
| 940 | let v:colornames['a redish white'] = '#ffeedd' |
| 941 | highlight Normal guifg='a redish white' |
| 942 | highlight clear |
| 943 | endfunc |
| 944 | |
| 945 | func Test_colornames_default_list() |
| 946 | " Ensure default lists are loaded automatically and can be used for all gui fields. |
| 947 | highlight Normal guifg='rebecca purple' guibg='rebecca purple' guisp='rebecca purple' |
| 948 | highlight clear |
| 949 | endfunc |
| 950 | |
| 951 | func Test_colornames_overwrite_default() |
| 952 | " Ensure entries in v:colornames can be overwritten. |
| 953 | " Load default color scheme to trigger default color list loading. |
| 954 | colorscheme default |
| 955 | let old_rebecca_purple = v:colornames['rebecca purple'] |
| 956 | highlight Normal guifg='rebecca purple' guibg='rebecca purple' |
| 957 | let v:colornames['rebecca purple'] = '#550099' |
| 958 | highlight Normal guifg='rebecca purple' guibg='rebecca purple' |
| 959 | let v:colornames['rebecca purple'] = old_rebecca_purple |
| 960 | highlight clear |
| 961 | endfunc |
| 962 | |
| 963 | func Test_colornames_assignment_and_unassignment() |
| 964 | " Ensure we cannot overwrite the v:colornames dict. |
| 965 | call assert_fails("let v:colornames = {}", 'E46:') |
| 966 | |
| 967 | " Ensure we can delete entries from the v:colornames dict. |
| 968 | let v:colornames['x1'] = '#111111' |
| 969 | call assert_equal(v:colornames['x1'], '#111111') |
| 970 | unlet v:colornames['x1'] |
| 971 | call assert_fails("echo v:colornames['x1']") |
| 972 | endfunc |
| 973 | |
Yegappan Lakshmanan | d1a8d65 | 2021-11-03 21:56:45 +0000 | [diff] [blame] | 974 | " Test for the hlget() function |
| 975 | func Test_hlget() |
| 976 | let lines =<< trim END |
| 977 | call assert_notequal([], filter(hlget(), 'v:val.name == "Visual"')) |
| 978 | call assert_equal([], hlget('SomeHLGroup')) |
| 979 | highlight MyHLGroup term=standout cterm=reverse ctermfg=10 ctermbg=Black |
| 980 | call assert_equal([{'id': hlID('MyHLGroup'), 'ctermfg': '10', 'name': 'MyHLGroup', 'term': {'standout': v:true}, 'ctermbg': '0', 'cterm': {'reverse': v:true}}], hlget('MyHLGroup')) |
| 981 | highlight clear MyHLGroup |
| 982 | call assert_equal(v:true, hlget('MyHLGroup')[0].cleared) |
| 983 | highlight link MyHLGroup IncSearch |
| 984 | call assert_equal('IncSearch', hlget('MyHLGroup')[0].linksto) |
| 985 | highlight clear MyHLGroup |
| 986 | call assert_equal([], hlget(test_null_string())) |
| 987 | call assert_equal([], hlget("")) |
| 988 | END |
| 989 | call CheckLegacyAndVim9Success(lines) |
| 990 | |
| 991 | " Test for resolving highlight group links |
| 992 | let lines =<< trim END |
| 993 | highlight hlgA term=bold |
| 994 | VAR hlgAid = hlID('hlgA') |
| 995 | highlight link hlgB hlgA |
| 996 | VAR hlgBid = hlID('hlgB') |
| 997 | highlight link hlgC hlgB |
| 998 | VAR hlgCid = hlID('hlgC') |
| 999 | call assert_equal('hlgA', hlget('hlgB')[0].linksto) |
| 1000 | call assert_equal('hlgB', hlget('hlgC')[0].linksto) |
| 1001 | call assert_equal([{'id': hlgAid, 'name': 'hlgA', |
| 1002 | \ 'term': {'bold': v:true}}], hlget('hlgA')) |
| 1003 | call assert_equal([{'id': hlgBid, 'name': 'hlgB', |
| 1004 | \ 'linksto': 'hlgA'}], hlget('hlgB')) |
| 1005 | call assert_equal([{'id': hlgCid, 'name': 'hlgC', |
| 1006 | \ 'linksto': 'hlgB'}], hlget('hlgC')) |
| 1007 | call assert_equal([{'id': hlgAid, 'name': 'hlgA', |
| 1008 | \ 'term': {'bold': v:true}}], hlget('hlgA', v:false)) |
| 1009 | call assert_equal([{'id': hlgBid, 'name': 'hlgB', |
| 1010 | \ 'linksto': 'hlgA'}], hlget('hlgB', 0)) |
| 1011 | call assert_equal([{'id': hlgCid, 'name': 'hlgC', |
| 1012 | \ 'linksto': 'hlgB'}], hlget('hlgC', v:false)) |
| 1013 | call assert_equal([{'id': hlgAid, 'name': 'hlgA', |
| 1014 | \ 'term': {'bold': v:true}}], hlget('hlgA', v:true)) |
| 1015 | call assert_equal([{'id': hlgBid, 'name': 'hlgB', |
| 1016 | \ 'term': {'bold': v:true}}], hlget('hlgB', 1)) |
| 1017 | call assert_equal([{'id': hlgCid, 'name': 'hlgC', |
| 1018 | \ 'term': {'bold': v:true}}], hlget('hlgC', v:true)) |
| 1019 | END |
| 1020 | call CheckLegacyAndVim9Success(lines) |
| 1021 | |
| 1022 | call assert_fails('call hlget([])', 'E1174:') |
| 1023 | call assert_fails('call hlget("abc", "xyz")', 'E1212:') |
| 1024 | endfunc |
| 1025 | |
| 1026 | " Test for the hlset() function |
| 1027 | func Test_hlset() |
| 1028 | let lines =<< trim END |
| 1029 | call assert_equal(0, hlset(test_null_list())) |
| 1030 | call assert_equal(0, hlset([])) |
| 1031 | call assert_fails('call hlset(["Search"])', 'E715:') |
| 1032 | call hlset(hlget()) |
| 1033 | call hlset([{'name': 'NewHLGroup', 'cterm': {'reverse': v:true}, 'ctermfg': '10'}]) |
| 1034 | call assert_equal({'reverse': v:true}, hlget('NewHLGroup')[0].cterm) |
| 1035 | call hlset([{'name': 'NewHLGroup', 'cterm': {'bold': v:true}}]) |
| 1036 | call assert_equal({'bold': v:true}, hlget('NewHLGroup')[0].cterm) |
| 1037 | call hlset([{'name': 'NewHLGroup', 'cleared': v:true}]) |
| 1038 | call assert_equal(v:true, hlget('NewHLGroup')[0].cleared) |
| 1039 | call hlset([{'name': 'NewHLGroup', 'linksto': 'Search'}]) |
| 1040 | call assert_false(has_key(hlget('NewHLGroup')[0], 'cleared')) |
| 1041 | call assert_equal('Search', hlget('NewHLGroup')[0].linksto) |
| 1042 | call assert_fails("call hlset([{'name': [], 'ctermfg': '10'}])", 'E928:') |
| 1043 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'cleared': []}])", |
| 1044 | \ 'E745:') |
| 1045 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'cterm': 'Blue'}])", |
| 1046 | \ 'E715:') |
| 1047 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'ctermbg': []}])", |
| 1048 | \ 'E928:') |
| 1049 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'ctermfg': []}])", |
| 1050 | \ 'E928:') |
| 1051 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'ctermul': []}])", |
| 1052 | \ 'E928:') |
| 1053 | if has('gui') |
| 1054 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'font': []}])", |
| 1055 | \ 'E928:') |
| 1056 | endif |
| 1057 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'gui': 'Cyan'}])", |
| 1058 | \ 'E715:') |
| 1059 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'guibg': []}])", |
| 1060 | \ 'E928:') |
| 1061 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'guifg': []}])", |
| 1062 | \ 'E928:') |
| 1063 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'guisp': []}])", |
| 1064 | \ 'E928:') |
| 1065 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'linksto': []}])", |
| 1066 | \ 'E928:') |
| 1067 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'start': []}])", |
| 1068 | \ 'E928:') |
| 1069 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'stop': []}])", |
| 1070 | \ 'E928:') |
| 1071 | call assert_fails("call hlset([{'name': 'NewHLGroup', 'term': 'Cyan'}])", |
| 1072 | \ 'E715:') |
| 1073 | call assert_equal('Search', hlget('NewHLGroup')[0].linksto) |
| 1074 | highlight clear NewHLGroup |
| 1075 | END |
| 1076 | call CheckLegacyAndVim9Success(lines) |
| 1077 | |
| 1078 | " Test for clearing the 'term', 'cterm' and 'gui' attributes of a highlight |
| 1079 | " group. |
| 1080 | let lines =<< trim END |
| 1081 | highlight myhlg1 term=bold cterm=italic gui=standout |
| 1082 | VAR id = hlID('myhlg1') |
| 1083 | call hlset([{'name': 'myhlg1', 'term': {}}]) |
| 1084 | call assert_equal([{'id': id, 'name': 'myhlg1', |
| 1085 | \ 'cterm': {'italic': v:true}, 'gui': {'standout': v:true}}], |
| 1086 | \ hlget('myhlg1')) |
| 1087 | call hlset([{'name': 'myhlg1', 'cterm': {}}]) |
| 1088 | call assert_equal([{'id': id, 'name': 'myhlg1', |
| 1089 | \ 'gui': {'standout': v:true}}], hlget('myhlg1')) |
| 1090 | call hlset([{'name': 'myhlg1', 'gui': {}}]) |
| 1091 | call assert_equal([{'id': id, 'name': 'myhlg1', 'cleared': v:true}], |
| 1092 | \ hlget('myhlg1')) |
| 1093 | highlight clear myhlg1 |
| 1094 | END |
| 1095 | call CheckLegacyAndVim9Success(lines) |
| 1096 | |
| 1097 | " Test for setting all the 'term', 'cterm' and 'gui' attributes of a |
| 1098 | " highlight group |
| 1099 | let lines =<< trim END |
| 1100 | VAR attr = {'bold': v:true, 'underline': v:true, 'undercurl': v:true, |
| 1101 | \ 'strikethrough': v:true, 'reverse': v:true, 'italic': v:true, |
| 1102 | \ 'standout': v:true, 'nocombine': v:true} |
| 1103 | call hlset([{'name': 'myhlg2', 'term': attr, 'cterm': attr, 'gui': attr}]) |
| 1104 | VAR id2 = hlID('myhlg2') |
| 1105 | VAR output =<< trim END |
| 1106 | myhlg2 xxx term=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough |
| 1107 | cterm=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough |
| 1108 | gui=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough |
| 1109 | END |
| 1110 | call assert_equal(output, execute('highlight myhlg2')->split("\n")) |
| 1111 | call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr, |
| 1112 | \ 'term': attr, 'cterm': attr}], hlget('myhlg2')) |
| 1113 | END |
| 1114 | call CheckLegacyAndVim9Success(lines) |
| 1115 | |
| 1116 | " Test for clearing some of the 'term', 'cterm' and 'gui' attributes of a |
| 1117 | " highlight group |
| 1118 | let lines =<< trim END |
| 1119 | VAR attr = {'bold': v:false, 'underline': v:true, 'strikethrough': v:true} |
| 1120 | call hlset([{'name': 'myhlg2', 'term': attr, 'cterm': attr, 'gui': attr}]) |
| 1121 | VAR id2 = hlID('myhlg2') |
| 1122 | VAR output =<< trim END |
| 1123 | myhlg2 xxx term=underline,strikethrough cterm=underline,strikethrough |
| 1124 | gui=underline,strikethrough |
| 1125 | END |
| 1126 | call assert_equal(output, execute('highlight myhlg2')->split("\n")) |
| 1127 | LET attr = {'underline': v:true, 'strikethrough': v:true} |
| 1128 | call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr, |
| 1129 | \ 'term': attr, 'cterm': attr}], hlget('myhlg2')) |
| 1130 | END |
| 1131 | call CheckLegacyAndVim9Success(lines) |
| 1132 | endfunc |
| 1133 | |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 1134 | " vim: shiftwidth=2 sts=2 expandtab |