Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 1 | " Tests for 'listchars' display with 'list' and :list |
| 2 | |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 3 | source check.vim |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 4 | source view_util.vim |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 5 | source screendump.vim |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 6 | |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 7 | func Check_listchars(expected, end_lnum, end_scol = -1, leftcol = 0) |
| 8 | if a:leftcol > 0 |
| 9 | let save_wrap = &wrap |
| 10 | set nowrap |
| 11 | call cursor(1, 1) |
| 12 | exe 'normal! ' .. a:leftcol .. 'zl' |
| 13 | endif |
| 14 | |
| 15 | redraw! |
| 16 | for i in range(1, a:end_lnum) |
| 17 | if a:leftcol > 0 |
| 18 | let col = virtcol2col(0, i, a:leftcol) |
| 19 | let col += getline(i)->strpart(col - 1, 1, v:true)->len() |
| 20 | call cursor(i, col) |
| 21 | redraw |
| 22 | call assert_equal(a:leftcol, winsaveview().leftcol) |
| 23 | else |
| 24 | call cursor(i, 1) |
| 25 | end |
| 26 | |
| 27 | let end_scol = a:end_scol < 0 ? '$'->virtcol() - a:leftcol : a:end_scol |
| 28 | call assert_equal([a:expected[i - 1]->strcharpart(a:leftcol)], |
| 29 | \ ScreenLines(i, end_scol)) |
| 30 | endfor |
| 31 | |
| 32 | if a:leftcol > 0 |
| 33 | let &wrap = save_wrap |
| 34 | endif |
| 35 | endfunc |
| 36 | |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 37 | func Test_listchars() |
| 38 | enew! |
| 39 | set ff=unix |
| 40 | set list |
| 41 | |
| 42 | set listchars+=tab:>-,space:.,trail:< |
| 43 | call append(0, [ |
| 44 | \ ' aa ', |
| 45 | \ ' bb ', |
| 46 | \ ' cccc ', |
| 47 | \ 'dd ee ', |
| 48 | \ ' ' |
| 49 | \ ]) |
| 50 | let expected = [ |
| 51 | \ '>-------aa>-----$', |
| 52 | \ '..bb>---<<$', |
| 53 | \ '...cccc><$', |
| 54 | \ 'dd........ee<<>-$', |
| 55 | \ '<$' |
| 56 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 57 | call Check_listchars(expected, 5) |
| 58 | call Check_listchars(expected, 4, -1, 5) |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 59 | |
| 60 | set listchars-=trail:< |
| 61 | let expected = [ |
| 62 | \ '>-------aa>-----$', |
| 63 | \ '..bb>---..$', |
| 64 | \ '...cccc>.$', |
| 65 | \ 'dd........ee..>-$', |
| 66 | \ '.$' |
| 67 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 68 | call Check_listchars(expected, 5) |
| 69 | call Check_listchars(expected, 4, -1, 5) |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 70 | |
Bram Moolenaar | 83a5217 | 2019-01-16 22:41:54 +0100 | [diff] [blame] | 71 | " tab with 3rd character. |
| 72 | set listchars-=tab:>- |
| 73 | set listchars+=tab:<=>,trail:- |
| 74 | let expected = [ |
| 75 | \ '<======>aa<====>$', |
| 76 | \ '..bb<==>--$', |
| 77 | \ '...cccc>-$', |
| 78 | \ 'dd........ee--<>$', |
| 79 | \ '-$' |
| 80 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 81 | call Check_listchars(expected, 5) |
| 82 | call Check_listchars(expected, 4, -1, 5) |
Bram Moolenaar | 83a5217 | 2019-01-16 22:41:54 +0100 | [diff] [blame] | 83 | |
Bram Moolenaar | 69cbbec | 2019-08-17 14:10:56 +0200 | [diff] [blame] | 84 | " tab with 3rd character and linebreak set |
| 85 | set listchars-=tab:<=> |
| 86 | set listchars+=tab:<·> |
| 87 | set linebreak |
| 88 | let expected = [ |
| 89 | \ '<······>aa<····>$', |
| 90 | \ '..bb<··>--$', |
| 91 | \ '...cccc>-$', |
| 92 | \ 'dd........ee--<>$', |
| 93 | \ '-$' |
| 94 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 95 | call Check_listchars(expected, 5) |
Bram Moolenaar | 69cbbec | 2019-08-17 14:10:56 +0200 | [diff] [blame] | 96 | set nolinebreak |
| 97 | set listchars-=tab:<·> |
| 98 | set listchars+=tab:<=> |
| 99 | |
Bram Moolenaar | 83a5217 | 2019-01-16 22:41:54 +0100 | [diff] [blame] | 100 | set listchars-=trail:- |
| 101 | let expected = [ |
| 102 | \ '<======>aa<====>$', |
| 103 | \ '..bb<==>..$', |
| 104 | \ '...cccc>.$', |
| 105 | \ 'dd........ee..<>$', |
| 106 | \ '.$' |
| 107 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 108 | call Check_listchars(expected, 5) |
| 109 | call Check_listchars(expected, 4, -1, 5) |
Bram Moolenaar | 83a5217 | 2019-01-16 22:41:54 +0100 | [diff] [blame] | 110 | |
| 111 | set listchars-=tab:<=> |
| 112 | set listchars+=tab:>- |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 113 | set listchars+=trail:< |
| 114 | set nolist |
| 115 | normal ggdG |
| 116 | call append(0, [ |
| 117 | \ ' fff ', |
| 118 | \ ' gg ', |
| 119 | \ ' h ', |
| 120 | \ 'iii ', |
| 121 | \ ]) |
| 122 | let l = split(execute("%list"), "\n") |
| 123 | call assert_equal([ |
| 124 | \ '..fff>--<<$', |
| 125 | \ '>-------gg>-----$', |
| 126 | \ '.....h>-$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 127 | \ 'iii<<<<><<$', |
| 128 | \ '$'], l) |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 129 | |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 130 | " Test lead and trail |
| 131 | normal ggdG |
| 132 | set listchars& |
| 133 | set listchars+=lead:>,trail:<,space:x |
| 134 | set list |
| 135 | |
| 136 | call append(0, [ |
| 137 | \ ' ffff ', |
| 138 | \ ' gg', |
| 139 | \ 'h ', |
| 140 | \ ' ', |
| 141 | \ ' 0 0 ', |
| 142 | \ ]) |
| 143 | |
| 144 | let expected = [ |
| 145 | \ '>>>>ffff<<<<$', |
| 146 | \ '>>>>>>>>>>gg$', |
| 147 | \ 'h<<<<<<<<<<<$', |
| 148 | \ '<<<<<<<<<<<<$', |
| 149 | \ '>>>>0xx0<<<<$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 150 | \ '$' |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 151 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 152 | call Check_listchars(expected, 6) |
| 153 | call Check_listchars(expected, 5, -1, 6) |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 154 | call assert_equal(expected, split(execute("%list"), "\n")) |
Bram Moolenaar | 895d966 | 2019-01-31 21:57:21 +0100 | [diff] [blame] | 155 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 156 | " Test multispace |
| 157 | normal ggdG |
| 158 | set listchars& |
| 159 | set listchars+=multispace:yYzZ |
| 160 | set list |
| 161 | |
| 162 | call append(0, [ |
| 163 | \ ' ffff ', |
| 164 | \ ' i i gg', |
| 165 | \ ' h ', |
| 166 | \ ' j ', |
| 167 | \ ' 0 0 ', |
| 168 | \ ]) |
| 169 | |
| 170 | let expected = [ |
| 171 | \ 'yYzZffffyYzZ$', |
| 172 | \ 'yYi iyYzZygg$', |
| 173 | \ ' hyYzZyYzZyY$', |
| 174 | \ 'yYzZyYzZyYj $', |
| 175 | \ 'yYzZ0yY0yYzZ$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 176 | \ '$' |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 177 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 178 | call Check_listchars(expected, 6) |
| 179 | call Check_listchars(expected, 5, -1, 6) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 180 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 181 | |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 182 | " Test leadmultispace + multispace |
| 183 | normal ggdG |
| 184 | set listchars=eol:$,multispace:yYzZ,nbsp:S |
| 185 | set listchars+=leadmultispace:.-+* |
| 186 | set list |
| 187 | |
| 188 | call append(0, [ |
| 189 | \ ' ffff ', |
| 190 | \ ' i i gg', |
| 191 | \ ' h ', |
| 192 | \ ' j ', |
| 193 | \ ' 0 0 ', |
| 194 | \ ]) |
| 195 | |
| 196 | let expected = [ |
| 197 | \ '.-+*ffffyYzZ$', |
| 198 | \ '.-i iSyYzZgg$', |
| 199 | \ ' hyYzZyYzZyY$', |
| 200 | \ '.-+*.-+*.-j $', |
| 201 | \ '.-+*0yY0yYzZ$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 202 | \ '$' |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 203 | \ ] |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 204 | call assert_equal('eol:$,multispace:yYzZ,nbsp:S,leadmultispace:.-+*', &listchars) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 205 | call Check_listchars(expected, 6) |
| 206 | call Check_listchars(expected, 5, -1, 1) |
| 207 | call Check_listchars(expected, 5, -1, 2) |
| 208 | call Check_listchars(expected, 5, -1, 3) |
| 209 | call Check_listchars(expected, 5, -1, 6) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 210 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 211 | |
| 212 | " Test leadmultispace without multispace |
| 213 | normal ggdG |
| 214 | set listchars-=multispace:yYzZ |
| 215 | set listchars+=space:+,trail:>,eol:$ |
| 216 | set list |
| 217 | |
| 218 | call append(0, [ |
| 219 | \ ' ffff ', |
| 220 | \ ' i i gg', |
| 221 | \ ' h ', |
| 222 | \ ' j ', |
| 223 | \ ' 0 0 ', |
| 224 | \ ]) |
| 225 | |
| 226 | let expected = [ |
| 227 | \ '.-+*ffff>>>>$', |
| 228 | \ '.-i+i+++++gg$', |
| 229 | \ '+h>>>>>>>>>>$', |
| 230 | \ '.-+*.-+*.-j>$', |
| 231 | \ '.-+*0++0>>>>$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 232 | \ '$' |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 233 | \ ] |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 234 | call assert_equal('eol:$,nbsp:S,leadmultispace:.-+*,space:+,trail:>,eol:$', &listchars) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 235 | call Check_listchars(expected, 6) |
| 236 | call Check_listchars(expected, 5, -1, 1) |
| 237 | call Check_listchars(expected, 5, -1, 2) |
| 238 | call Check_listchars(expected, 5, -1, 3) |
| 239 | call Check_listchars(expected, 5, -1, 6) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 240 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 241 | |
| 242 | " Test leadmultispace only |
| 243 | normal ggdG |
| 244 | set listchars& |
| 245 | set listchars=leadmultispace:.-+* |
| 246 | set list |
| 247 | |
| 248 | call append(0, [ |
| 249 | \ ' ffff ', |
| 250 | \ ' i i gg', |
| 251 | \ ' h ', |
| 252 | \ ' j ', |
| 253 | \ ' 0 0 ', |
| 254 | \ ]) |
| 255 | |
| 256 | let expected = [ |
| 257 | \ '.-+*ffff ', |
| 258 | \ '.-i i gg', |
| 259 | \ ' h ', |
| 260 | \ '.-+*.-+*.-j ', |
| 261 | \ '.-+*0 0 ', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 262 | \ ' ' |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 263 | \ ] |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 264 | call assert_equal('leadmultispace:.-+*', &listchars) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 265 | call Check_listchars(expected, 5, 12) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 266 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 267 | |
zeertzjq | 00624a2 | 2023-11-23 20:47:16 +0100 | [diff] [blame] | 268 | " Changing the value of 'ambiwidth' twice shouldn't cause double-free when |
| 269 | " "leadmultispace" is specified. |
| 270 | set ambiwidth=double |
| 271 | set ambiwidth& |
| 272 | |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 273 | " Test leadmultispace and lead and space |
| 274 | normal ggdG |
| 275 | set listchars& |
| 276 | set listchars+=lead:<,space:- |
| 277 | set listchars+=leadmultispace:.-+* |
| 278 | set list |
| 279 | |
| 280 | call append(0, [ |
| 281 | \ ' ffff ', |
| 282 | \ ' i i gg', |
| 283 | \ ' h ', |
| 284 | \ ' j ', |
| 285 | \ ' 0 0 ', |
| 286 | \ ]) |
| 287 | |
| 288 | let expected = [ |
| 289 | \ '.-+*ffff----$', |
| 290 | \ '.-i-i-----gg$', |
| 291 | \ '<h----------$', |
| 292 | \ '.-+*.-+*.-j-$', |
| 293 | \ '.-+*0--0----$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 294 | \ '$' |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 295 | \ ] |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 296 | call assert_equal('eol:$,lead:<,space:-,leadmultispace:.-+*', &listchars) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 297 | call Check_listchars(expected, 6) |
| 298 | call Check_listchars(expected, 5, -1, 1) |
| 299 | call Check_listchars(expected, 5, -1, 2) |
| 300 | call Check_listchars(expected, 5, -1, 3) |
| 301 | call Check_listchars(expected, 5, -1, 6) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 302 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 303 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 304 | " the last occurrence of 'multispace:' is used |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 305 | set listchars& |
| 306 | set listchars+=multispace:yYzZ |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 307 | set listchars+=space:x,multispace:XyY |
| 308 | |
| 309 | let expected = [ |
| 310 | \ 'XyYXffffXyYX$', |
| 311 | \ 'XyixiXyYXygg$', |
| 312 | \ 'xhXyYXyYXyYX$', |
| 313 | \ 'XyYXyYXyYXjx$', |
| 314 | \ 'XyYX0Xy0XyYX$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 315 | \ '$' |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 316 | \ ] |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 317 | call assert_equal('eol:$,multispace:yYzZ,space:x,multispace:XyY', &listchars) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 318 | call Check_listchars(expected, 6) |
| 319 | call Check_listchars(expected, 5, -1, 6) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 320 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 321 | |
| 322 | set listchars+=lead:>,trail:< |
| 323 | |
| 324 | let expected = [ |
| 325 | \ '>>>>ffff<<<<$', |
| 326 | \ '>>ixiXyYXygg$', |
| 327 | \ '>h<<<<<<<<<<$', |
| 328 | \ '>>>>>>>>>>j<$', |
| 329 | \ '>>>>0Xy0<<<<$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 330 | \ '$' |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 331 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 332 | call Check_listchars(expected, 6) |
| 333 | call Check_listchars(expected, 5, -1, 6) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 334 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 335 | |
| 336 | " removing 'multispace:' |
| 337 | set listchars-=multispace:XyY |
| 338 | set listchars-=multispace:yYzZ |
| 339 | |
| 340 | let expected = [ |
| 341 | \ '>>>>ffff<<<<$', |
| 342 | \ '>>ixixxxxxgg$', |
| 343 | \ '>h<<<<<<<<<<$', |
| 344 | \ '>>>>>>>>>>j<$', |
| 345 | \ '>>>>0xx0<<<<$', |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 346 | \ '$' |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 347 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 348 | call Check_listchars(expected, 6) |
| 349 | call Check_listchars(expected, 5, -1, 6) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 350 | call assert_equal(expected, split(execute("%list"), "\n")) |
| 351 | |
Bram Moolenaar | 895d966 | 2019-01-31 21:57:21 +0100 | [diff] [blame] | 352 | " test nbsp |
| 353 | normal ggdG |
| 354 | set listchars=nbsp:X,trail:Y |
| 355 | set list |
| 356 | " Non-breaking space |
| 357 | let nbsp = nr2char(0xa0) |
Bram Moolenaar | f138728 | 2021-03-22 17:11:15 +0100 | [diff] [blame] | 358 | call append(0, [ ">" .. nbsp .. "<" ]) |
Bram Moolenaar | 895d966 | 2019-01-31 21:57:21 +0100 | [diff] [blame] | 359 | |
| 360 | let expected = '>X< ' |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 361 | call Check_listchars([expected], 1) |
Bram Moolenaar | 895d966 | 2019-01-31 21:57:21 +0100 | [diff] [blame] | 362 | |
| 363 | set listchars=nbsp:X |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 364 | call Check_listchars([expected], 1) |
Bram Moolenaar | 895d966 | 2019-01-31 21:57:21 +0100 | [diff] [blame] | 365 | |
Bram Moolenaar | a5c6a0b | 2019-05-08 20:20:46 +0200 | [diff] [blame] | 366 | " test extends |
| 367 | normal ggdG |
| 368 | set listchars=extends:Z |
| 369 | set nowrap |
| 370 | set nolist |
| 371 | call append(0, [ repeat('A', &columns + 1) ]) |
| 372 | |
| 373 | let expected = repeat('A', &columns) |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 374 | call Check_listchars([expected], 1, &columns) |
Bram Moolenaar | a5c6a0b | 2019-05-08 20:20:46 +0200 | [diff] [blame] | 375 | |
| 376 | set list |
| 377 | let expected = expected[:-2] . 'Z' |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 378 | call Check_listchars([expected], 1, &columns) |
Bram Moolenaar | a5c6a0b | 2019-05-08 20:20:46 +0200 | [diff] [blame] | 379 | |
Bram Moolenaar | 209d387 | 2017-11-16 21:52:51 +0100 | [diff] [blame] | 380 | enew! |
| 381 | set listchars& ff& |
| 382 | endfunc |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 383 | |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 384 | " Test that unicode listchars characters get properly inserted |
| 385 | func Test_listchars_unicode() |
| 386 | enew! |
| 387 | let oldencoding=&encoding |
| 388 | set encoding=utf-8 |
| 389 | set ff=unix |
| 390 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 391 | set listchars=eol:⇔,space:␣,multispace:≡≢≣,nbsp:≠,tab:←↔→ |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 392 | set list |
| 393 | |
| 394 | let nbsp = nr2char(0xa0) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 395 | call append(0, [" a\tb c" .. nbsp .. "d "]) |
| 396 | let expected = ['≡≢≣≡≢≣≡≢a←↔↔↔↔↔→b␣c≠d≡≢⇔'] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 397 | call Check_listchars(expected, 1) |
| 398 | call Check_listchars(expected, 1, -1, 3) |
| 399 | call Check_listchars(expected, 1, -1, 13) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 400 | |
Bram Moolenaar | 93ff672 | 2021-10-16 17:51:40 +0100 | [diff] [blame] | 401 | set listchars=eol:\\u21d4,space:\\u2423,multispace:≡\\u2262\\U00002263,nbsp:\\U00002260,tab:←↔\\u2192 |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 402 | call Check_listchars(expected, 1) |
| 403 | call Check_listchars(expected, 1, -1, 3) |
| 404 | call Check_listchars(expected, 1, -1, 13) |
Bram Moolenaar | 93ff672 | 2021-10-16 17:51:40 +0100 | [diff] [blame] | 405 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 406 | set listchars+=lead:⇨,trail:⇦ |
| 407 | let expected = ['⇨⇨⇨⇨⇨⇨⇨⇨a←↔↔↔↔↔→b␣c≠d⇦⇦⇔'] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 408 | call Check_listchars(expected, 1) |
| 409 | call Check_listchars(expected, 1, -1, 3) |
| 410 | call Check_listchars(expected, 1, -1, 13) |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 411 | |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 412 | let &encoding=oldencoding |
| 413 | enew! |
| 414 | set listchars& ff& |
| 415 | endfunction |
| 416 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 417 | func Test_listchars_invalid() |
| 418 | enew! |
| 419 | set ff=unix |
| 420 | |
| 421 | set listchars& |
| 422 | set list |
| 423 | set ambiwidth=double |
| 424 | |
| 425 | " No colon |
| 426 | call assert_fails('set listchars=x', 'E474:') |
| 427 | call assert_fails('set listchars=x', 'E474:') |
| 428 | call assert_fails('set listchars=multispace', 'E474:') |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 429 | call assert_fails('set listchars=leadmultispace', 'E474:') |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 430 | |
| 431 | " Too short |
zeertzjq | 6a8d2e1 | 2024-01-17 20:54:49 +0100 | [diff] [blame] | 432 | call assert_fails('set listchars=space:', 'E1511:') |
| 433 | call assert_fails('set listchars=tab:x', 'E1511:') |
| 434 | call assert_fails('set listchars=multispace:', 'E1511:') |
| 435 | call assert_fails('set listchars=leadmultispace:', 'E1511:') |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 436 | |
| 437 | " One occurrence too short |
zeertzjq | 6a8d2e1 | 2024-01-17 20:54:49 +0100 | [diff] [blame] | 438 | call assert_fails('set listchars=space:x,space:', 'E1511:') |
| 439 | call assert_fails('set listchars=space:,space:x', 'E1511:') |
| 440 | call assert_fails('set listchars=tab:xx,tab:x', 'E1511:') |
| 441 | call assert_fails('set listchars=tab:x,tab:xx', 'E1511:') |
| 442 | call assert_fails('set listchars=multispace:,multispace:x', 'E1511:') |
| 443 | call assert_fails('set listchars=multispace:x,multispace:', 'E1511:') |
| 444 | call assert_fails('set listchars=leadmultispace:,leadmultispace:x', 'E1511:') |
| 445 | call assert_fails('set listchars=leadmultispace:x,leadmultispace:', 'E1511:') |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 446 | |
| 447 | " Too long |
zeertzjq | 6a8d2e1 | 2024-01-17 20:54:49 +0100 | [diff] [blame] | 448 | call assert_fails('set listchars=space:xx', 'E1511:') |
| 449 | call assert_fails('set listchars=tab:xxxx', 'E1511:') |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 450 | |
zeertzjq | 60618c8 | 2021-12-18 15:32:46 +0000 | [diff] [blame] | 451 | " Has double-width character |
zeertzjq | 6a8d2e1 | 2024-01-17 20:54:49 +0100 | [diff] [blame] | 452 | call assert_fails('set listchars=space:·', 'E1512:') |
| 453 | call assert_fails('set listchars=tab:·x', 'E1512:') |
| 454 | call assert_fails('set listchars=tab:x·', 'E1512:') |
| 455 | call assert_fails('set listchars=tab:xx·', 'E1512:') |
| 456 | call assert_fails('set listchars=multispace:·', 'E1512:') |
| 457 | call assert_fails('set listchars=multispace:xxx·', 'E1512:') |
| 458 | call assert_fails('set listchars=leadmultispace:·', 'E1512:') |
| 459 | call assert_fails('set listchars=leadmultispace:xxx·', 'E1512:') |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 460 | |
zeertzjq | 60618c8 | 2021-12-18 15:32:46 +0000 | [diff] [blame] | 461 | " Has control character |
zeertzjq | 6a8d2e1 | 2024-01-17 20:54:49 +0100 | [diff] [blame] | 462 | call assert_fails("set listchars=space:\x01", 'E1512:') |
| 463 | call assert_fails("set listchars=tab:\x01x", 'E1512:') |
| 464 | call assert_fails("set listchars=tab:x\x01", 'E1512:') |
| 465 | call assert_fails("set listchars=tab:xx\x01", 'E1512:') |
| 466 | call assert_fails("set listchars=multispace:\x01", 'E1512:') |
| 467 | call assert_fails("set listchars=multispace:xxx\x01", 'E1512:') |
| 468 | call assert_fails('set listchars=space:\\x01', 'E1512:') |
| 469 | call assert_fails('set listchars=tab:\\x01x', 'E1512:') |
| 470 | call assert_fails('set listchars=tab:x\\x01', 'E1512:') |
| 471 | call assert_fails('set listchars=tab:xx\\x01', 'E1512:') |
| 472 | call assert_fails('set listchars=multispace:\\x01', 'E1512:') |
| 473 | call assert_fails('set listchars=multispace:xxx\\x01', 'E1512:') |
| 474 | call assert_fails("set listchars=leadmultispace:\x01", 'E1512:') |
| 475 | call assert_fails('set listchars=leadmultispace:\\x01', 'E1512:') |
| 476 | call assert_fails("set listchars=leadmultispace:xxx\x01", 'E1512:') |
| 477 | call assert_fails('set listchars=leadmultispace:xxx\\x01', 'E1512:') |
zeertzjq | 60618c8 | 2021-12-18 15:32:46 +0000 | [diff] [blame] | 478 | |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 479 | enew! |
| 480 | set ambiwidth& listchars& ff& |
| 481 | endfunction |
| 482 | |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 483 | " Tests that space characters following composing character won't get replaced |
| 484 | " by listchars. |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 485 | func Test_listchars_composing() |
| 486 | enew! |
| 487 | let oldencoding=&encoding |
| 488 | set encoding=utf-8 |
| 489 | set ff=unix |
| 490 | set list |
| 491 | |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 492 | set listchars=eol:$,space:_,nbsp:= |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 493 | |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 494 | let nbsp1 = nr2char(0xa0) |
| 495 | let nbsp2 = nr2char(0x202f) |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 496 | call append(0, [ |
Bram Moolenaar | f138728 | 2021-03-22 17:11:15 +0100 | [diff] [blame] | 497 | \ " \u3099\t \u309A" .. nbsp1 .. nbsp1 .. "\u0302" .. nbsp2 .. nbsp2 .. "\u0302", |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 498 | \ ]) |
| 499 | let expected = [ |
Bram Moolenaar | f138728 | 2021-03-22 17:11:15 +0100 | [diff] [blame] | 500 | \ "_ \u3099^I \u309A=" .. nbsp1 .. "\u0302=" .. nbsp2 .. "\u0302$" |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 501 | \ ] |
zeertzjq | abc8081 | 2023-09-24 23:32:18 +0200 | [diff] [blame] | 502 | call Check_listchars(expected, 1) |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 503 | let &encoding=oldencoding |
Bram Moolenaar | e5e4e22 | 2019-04-04 13:28:45 +0200 | [diff] [blame] | 504 | enew! |
Bram Moolenaar | 5f8069b | 2019-03-30 15:34:47 +0100 | [diff] [blame] | 505 | set listchars& ff& |
| 506 | endfunction |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 507 | |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 508 | " Check for the value of the 'listchars' option |
| 509 | func s:CheckListCharsValue(expected) |
| 510 | call assert_equal(a:expected, &listchars) |
| 511 | call assert_equal(a:expected, getwinvar(0, '&listchars')) |
| 512 | endfunc |
| 513 | |
| 514 | " Test for using a window local value for 'listchars' |
| 515 | func Test_listchars_window_local() |
| 516 | %bw! |
| 517 | set list listchars& |
| 518 | new |
| 519 | " set a local value for 'listchars' |
| 520 | setlocal listchars=tab:+-,eol:# |
| 521 | call s:CheckListCharsValue('tab:+-,eol:#') |
| 522 | " When local value is reset, global value should be used |
| 523 | setlocal listchars= |
| 524 | call s:CheckListCharsValue('eol:$') |
| 525 | " Use 'setlocal <' to copy global value |
| 526 | setlocal listchars=space:.,extends:> |
| 527 | setlocal listchars< |
| 528 | call s:CheckListCharsValue('eol:$') |
| 529 | " Use 'set <' to copy global value |
| 530 | setlocal listchars=space:.,extends:> |
| 531 | set listchars< |
| 532 | call s:CheckListCharsValue('eol:$') |
| 533 | " Changing global setting should not change the local setting |
| 534 | setlocal listchars=space:.,extends:> |
| 535 | setglobal listchars=tab:+-,eol:# |
| 536 | call s:CheckListCharsValue('space:.,extends:>') |
| 537 | " when split opening a new window, local value should be copied |
| 538 | split |
| 539 | call s:CheckListCharsValue('space:.,extends:>') |
| 540 | " clearing local value in one window should not change the other window |
| 541 | set listchars& |
| 542 | call s:CheckListCharsValue('eol:$') |
| 543 | close |
| 544 | call s:CheckListCharsValue('space:.,extends:>') |
| 545 | |
| 546 | " use different values for 'listchars' items in two different windows |
| 547 | call setline(1, ["\t one two "]) |
| 548 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 549 | split |
| 550 | setlocal listchars=tab:[.],lead:#,space:_,trail:.,eol:& |
| 551 | split |
| 552 | set listchars=tab:+-+,lead:^,space:>,trail:<,eol:% |
| 553 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 554 | close |
| 555 | call assert_equal(['[......]##one__two..&'], ScreenLines(1, virtcol('$'))) |
| 556 | close |
| 557 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 558 | " changing the global setting should not change the local value |
| 559 | setglobal listchars=tab:[.],lead:#,space:_,trail:.,eol:& |
| 560 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 561 | set listchars< |
| 562 | call assert_equal(['[......]##one__two..&'], ScreenLines(1, virtcol('$'))) |
| 563 | |
| 564 | " Using setglobal in a window with local setting should not affect the |
| 565 | " window. But should impact other windows using the global setting. |
| 566 | enew! | only |
| 567 | call setline(1, ["\t one two "]) |
| 568 | set listchars=tab:[.],lead:#,space:_,trail:.,eol:& |
| 569 | split |
| 570 | setlocal listchars=tab:+-+,lead:^,space:>,trail:<,eol:% |
| 571 | split |
| 572 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 573 | setglobal listchars=tab:{.},lead:-,space:=,trail:#,eol:$ |
| 574 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 575 | close |
| 576 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 577 | close |
| 578 | call assert_equal(['{......}--one==two##$'], ScreenLines(1, virtcol('$'))) |
| 579 | |
| 580 | " Setting the global setting to the default value should not impact a window |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 581 | " using a local setting. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 582 | split |
| 583 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 584 | setglobal listchars&vim |
| 585 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 586 | close |
| 587 | call assert_equal(['^I one two $'], ScreenLines(1, virtcol('$'))) |
| 588 | |
| 589 | " Setting the local setting to the default value should not impact a window |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 590 | " using a global setting. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 591 | set listchars=tab:{.},lead:-,space:=,trail:#,eol:$ |
| 592 | split |
| 593 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 594 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 595 | setlocal listchars&vim |
| 596 | call assert_equal(['^I one two $'], ScreenLines(1, virtcol('$'))) |
| 597 | close |
| 598 | call assert_equal(['{......}--one==two##$'], ScreenLines(1, virtcol('$'))) |
| 599 | |
| 600 | " Using set in a window with a local setting should change it to use the |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 601 | " global setting and also impact other windows using the global setting. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 602 | split |
| 603 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 604 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 605 | set listchars=tab:+-+,lead:^,space:>,trail:<,eol:% |
| 606 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 607 | close |
| 608 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 609 | |
Bram Moolenaar | 04ea7e9 | 2021-02-16 21:14:33 +0100 | [diff] [blame] | 610 | " Setting invalid value for a local setting should not impact the local and |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 611 | " global settings. |
Bram Moolenaar | 04ea7e9 | 2021-02-16 21:14:33 +0100 | [diff] [blame] | 612 | split |
| 613 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 614 | let cmd = 'setlocal listchars=tab:{.},lead:-,space:=,trail:#,eol:$,x' |
| 615 | call assert_fails(cmd, 'E474:') |
| 616 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 617 | close |
| 618 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 619 | |
| 620 | " Setting invalid value for a global setting should not impact the local and |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 621 | " global settings. |
Bram Moolenaar | 04ea7e9 | 2021-02-16 21:14:33 +0100 | [diff] [blame] | 622 | split |
| 623 | setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:# |
| 624 | let cmd = 'setglobal listchars=tab:{.},lead:-,space:=,trail:#,eol:$,x' |
| 625 | call assert_fails(cmd, 'E474:') |
| 626 | call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$'))) |
| 627 | close |
| 628 | call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$'))) |
| 629 | |
zeertzjq | 7a33ebf | 2021-11-02 20:56:07 +0000 | [diff] [blame] | 630 | " Closing window with local lcs-multispace should not cause a memory leak. |
| 631 | setlocal listchars=multispace:---+ |
| 632 | split |
| 633 | call s:CheckListCharsValue('multispace:---+') |
| 634 | close |
| 635 | |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 636 | %bw! |
| 637 | set list& listchars& |
| 638 | endfunc |
| 639 | |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 640 | func Test_listchars_foldcolumn() |
| 641 | CheckScreendump |
| 642 | |
| 643 | let lines =<< trim END |
| 644 | call setline(1, ['aaa', '', 'a', 'aaaaaa']) |
| 645 | vsplit |
| 646 | vsplit |
| 647 | windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:< |
| 648 | END |
Bram Moolenaar | 7dd5a78 | 2022-09-29 21:01:57 +0100 | [diff] [blame] | 649 | call writefile(lines, 'XTest_listchars', 'D') |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 650 | |
| 651 | let buf = RunVimInTerminal('-S XTest_listchars', {'rows': 10, 'cols': 60}) |
| 652 | |
| 653 | call term_sendkeys(buf, "13\<C-W>>") |
| 654 | call VerifyScreenDump(buf, 'Test_listchars_01', {}) |
| 655 | call term_sendkeys(buf, "\<C-W>>") |
| 656 | call VerifyScreenDump(buf, 'Test_listchars_02', {}) |
| 657 | call term_sendkeys(buf, "\<C-W>>") |
| 658 | call VerifyScreenDump(buf, 'Test_listchars_03', {}) |
| 659 | call term_sendkeys(buf, "\<C-W>>") |
| 660 | call VerifyScreenDump(buf, 'Test_listchars_04', {}) |
| 661 | call term_sendkeys(buf, "\<C-W>>") |
| 662 | call VerifyScreenDump(buf, 'Test_listchars_05', {}) |
Bram Moolenaar | 30441bb | 2021-07-08 13:19:31 +0200 | [diff] [blame] | 663 | call term_sendkeys(buf, "\<C-W>h") |
| 664 | call term_sendkeys(buf, ":set nowrap foldcolumn=4\<CR>") |
| 665 | call term_sendkeys(buf, "15\<C-W><") |
| 666 | call VerifyScreenDump(buf, 'Test_listchars_06', {}) |
| 667 | call term_sendkeys(buf, "4\<C-W><") |
| 668 | call VerifyScreenDump(buf, 'Test_listchars_07', {}) |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 669 | |
| 670 | " clean up |
| 671 | call StopVimInTerminal(buf) |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 672 | endfunc |
| 673 | |
zeertzjq | 08a83a0 | 2025-02-20 22:04:09 +0100 | [diff] [blame] | 674 | func Test_listchars_precedes_with_wide_char() |
| 675 | new |
| 676 | setlocal nowrap list listchars=eol:$,precedes:! |
| 677 | call setline(1, '123口456') |
| 678 | call assert_equal(['123口456$ '], ScreenLines(1, 10)) |
| 679 | let attr = screenattr(1, 9) |
zeertzjq | 13f100e | 2025-02-21 19:49:44 +0100 | [diff] [blame] | 680 | |
zeertzjq | 08a83a0 | 2025-02-20 22:04:09 +0100 | [diff] [blame] | 681 | normal! zl |
| 682 | call assert_equal(['!3口456$ '], ScreenLines(1, 10)) |
| 683 | call assert_equal(attr, screenattr(1, 1)) |
| 684 | normal! zl |
| 685 | call assert_equal(['!口456$ '], ScreenLines(1, 10)) |
| 686 | call assert_equal(attr, screenattr(1, 1)) |
| 687 | normal! zl |
| 688 | call assert_equal(['!<456$ '], ScreenLines(1, 10)) |
| 689 | call assert_equal(attr, screenattr(1, 1)) |
| 690 | call assert_equal(attr, screenattr(1, 2)) |
| 691 | normal! zl |
zeertzjq | 13f100e | 2025-02-21 19:49:44 +0100 | [diff] [blame] | 692 | call assert_equal(['!456$ '], ScreenLines(1, 10)) |
zeertzjq | 08a83a0 | 2025-02-20 22:04:09 +0100 | [diff] [blame] | 693 | call assert_equal(attr, screenattr(1, 1)) |
| 694 | normal! zl |
| 695 | call assert_equal(['!56$ '], ScreenLines(1, 10)) |
| 696 | call assert_equal(attr, screenattr(1, 1)) |
| 697 | normal! zl |
| 698 | call assert_equal(['!6$ '], ScreenLines(1, 10)) |
| 699 | call assert_equal(attr, screenattr(1, 1)) |
| 700 | |
| 701 | bw! |
| 702 | endfunc |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 703 | |
zeertzjq | 13f100e | 2025-02-21 19:49:44 +0100 | [diff] [blame] | 704 | func Test_listchars_precedes_with_tab() |
| 705 | new |
| 706 | setlocal nowrap list listchars=eol:$,precedes:!,tab:<-> |
| 707 | call setline(1, "1234\t56") |
| 708 | let expected_line = '1234<-->56$ ' |
| 709 | call assert_equal([expected_line], ScreenLines(1, 12)) |
| 710 | let expected_attrs = mapnew(range(1, 12), 'screenattr(1, v:val)') |
| 711 | let attr = expected_attrs[-2] |
| 712 | |
| 713 | for i in range(8) |
| 714 | normal! zl |
| 715 | let expected_line = '!' .. expected_line[2:] .. ' ' |
| 716 | let expected_attrs = [attr] + expected_attrs[2:] + expected_attrs[-1:] |
| 717 | call assert_equal([expected_line], ScreenLines(1, 12)) |
| 718 | let attrs = mapnew(range(1, 12), 'screenattr(1, v:val)') |
| 719 | call assert_equal(expected_attrs, attrs) |
| 720 | endfor |
| 721 | |
| 722 | bw! |
| 723 | endfunc |
| 724 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 725 | " vim: shiftwidth=2 sts=2 expandtab |