Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 1 | " Test for displaying stuff |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 3 | if !has('gui_running') && has('unix') |
| 4 | set term=ansi |
| 5 | endif |
| 6 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 7 | source view_util.vim |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 8 | source check.vim |
| 9 | source screendump.vim |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 10 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 11 | func Test_display_foldcolumn() |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 12 | CheckFeature folding |
| 13 | |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 14 | new |
| 15 | vnew |
| 16 | vert resize 25 |
Bram Moolenaar | 7089237 | 2016-12-09 19:51:49 +0100 | [diff] [blame] | 17 | call assert_equal(25, winwidth(winnr())) |
| 18 | set isprint=@ |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 19 | |
| 20 | 1put='e more noise blah blah more stuff here' |
| 21 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 22 | let expect = [ |
| 23 | \ "e more noise blah blah<82", |
| 24 | \ "> more stuff here " |
| 25 | \ ] |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 26 | |
| 27 | call cursor(2, 1) |
| 28 | norm! zt |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 29 | let lines = ScreenLines([1,2], winwidth(0)) |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 30 | call assert_equal(expect, lines) |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 31 | set fdc=2 |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 32 | let lines = ScreenLines([1,2], winwidth(0)) |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 33 | let expect = [ |
| 34 | \ " e more noise blah blah<", |
| 35 | \ " 82> more stuff here " |
| 36 | \ ] |
| 37 | call assert_equal(expect, lines) |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 38 | |
| 39 | quit! |
| 40 | quit! |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 41 | endfunc |
| 42 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 43 | func Test_display_foldtext_mbyte() |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 44 | CheckFeature folding |
| 45 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 46 | call NewWindow(10, 40) |
| 47 | call append(0, range(1,20)) |
| 48 | exe "set foldmethod=manual foldtext=foldtext() fillchars=fold:\u2500,vert:\u2502 fdc=2" |
| 49 | call cursor(2, 1) |
| 50 | norm! zf13G |
| 51 | let lines=ScreenLines([1,3], winwidth(0)+1) |
| 52 | let expect=[ |
| 53 | \ " 1 \u2502", |
| 54 | \ "+ +-- 12 lines: 2". repeat("\u2500", 23). "\u2502", |
| 55 | \ " 14 \u2502", |
| 56 | \ ] |
| 57 | call assert_equal(expect, lines) |
Bram Moolenaar | 8da1e6c | 2017-03-29 20:38:59 +0200 | [diff] [blame] | 58 | |
| 59 | set fillchars=fold:-,vert:\| |
| 60 | let lines=ScreenLines([1,3], winwidth(0)+1) |
| 61 | let expect=[ |
| 62 | \ " 1 |", |
| 63 | \ "+ +-- 12 lines: 2". repeat("-", 23). "|", |
| 64 | \ " 14 |", |
| 65 | \ ] |
| 66 | call assert_equal(expect, lines) |
| 67 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 68 | set foldtext& fillchars& foldmethod& fdc& |
| 69 | bw! |
| 70 | endfunc |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 71 | |
| 72 | " check that win_ins_lines() and win_del_lines() work when t_cs is empty. |
| 73 | func Test_scroll_without_region() |
| 74 | CheckScreendump |
| 75 | |
| 76 | let lines =<< trim END |
| 77 | call setline(1, range(1, 20)) |
| 78 | set t_cs= |
| 79 | set laststatus=2 |
| 80 | END |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 81 | call writefile(lines, 'Xtestscroll', 'D') |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 82 | let buf = RunVimInTerminal('-S Xtestscroll', #{rows: 10}) |
| 83 | |
| 84 | call VerifyScreenDump(buf, 'Test_scroll_no_region_1', {}) |
| 85 | |
| 86 | call term_sendkeys(buf, ":3delete\<cr>") |
| 87 | call VerifyScreenDump(buf, 'Test_scroll_no_region_2', {}) |
| 88 | |
| 89 | call term_sendkeys(buf, ":4put\<cr>") |
| 90 | call VerifyScreenDump(buf, 'Test_scroll_no_region_3', {}) |
| 91 | |
Bram Moolenaar | 7cc5351 | 2019-08-03 23:30:21 +0200 | [diff] [blame] | 92 | call term_sendkeys(buf, ":undo\<cr>") |
| 93 | call term_sendkeys(buf, ":undo\<cr>") |
| 94 | call term_sendkeys(buf, ":set laststatus=0\<cr>") |
| 95 | call VerifyScreenDump(buf, 'Test_scroll_no_region_4', {}) |
| 96 | |
| 97 | call term_sendkeys(buf, ":3delete\<cr>") |
| 98 | call VerifyScreenDump(buf, 'Test_scroll_no_region_5', {}) |
| 99 | |
| 100 | call term_sendkeys(buf, ":4put\<cr>") |
| 101 | call VerifyScreenDump(buf, 'Test_scroll_no_region_6', {}) |
| 102 | |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 103 | " clean up |
| 104 | call StopVimInTerminal(buf) |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 105 | endfunc |
Bram Moolenaar | bffba7f | 2019-09-20 17:00:17 +0200 | [diff] [blame] | 106 | |
| 107 | func Test_display_listchars_precedes() |
| 108 | call NewWindow(10, 10) |
| 109 | " Need a physical line that wraps over the complete |
| 110 | " window size |
| 111 | call append(0, repeat('aaa aaa aa ', 10)) |
| 112 | call append(1, repeat(['bbb bbb bbb bbb'], 2)) |
| 113 | " remove blank trailing line |
| 114 | $d |
| 115 | set list nowrap |
| 116 | call cursor(1, 1) |
| 117 | " move to end of line and scroll 2 characters back |
| 118 | norm! $2zh |
| 119 | let lines=ScreenLines([1,4], winwidth(0)+1) |
| 120 | let expect = [ |
| 121 | \ " aaa aa $ |", |
| 122 | \ "$ |", |
| 123 | \ "$ |", |
| 124 | \ "~ |", |
| 125 | \ ] |
| 126 | call assert_equal(expect, lines) |
| 127 | set list listchars+=precedes:< nowrap |
| 128 | call cursor(1, 1) |
| 129 | " move to end of line and scroll 2 characters back |
| 130 | norm! $2zh |
| 131 | let lines = ScreenLines([1,4], winwidth(0)+1) |
| 132 | let expect = [ |
| 133 | \ "<aaa aa $ |", |
| 134 | \ "< |", |
| 135 | \ "< |", |
| 136 | \ "~ |", |
| 137 | \ ] |
| 138 | call assert_equal(expect, lines) |
| 139 | set wrap |
| 140 | call cursor(1, 1) |
| 141 | " the complete line should be displayed in the window |
| 142 | norm! $ |
| 143 | |
| 144 | let lines = ScreenLines([1,10], winwidth(0)+1) |
| 145 | let expect = [ |
Bram Moolenaar | 297164c | 2022-10-15 14:24:29 +0100 | [diff] [blame] | 146 | \ "<aaa aaa a|", |
Bram Moolenaar | bffba7f | 2019-09-20 17:00:17 +0200 | [diff] [blame] | 147 | \ "a aaa aaa |", |
| 148 | \ "aa aaa aaa|", |
| 149 | \ " aa aaa aa|", |
| 150 | \ "a aa aaa a|", |
| 151 | \ "aa aa aaa |", |
| 152 | \ "aaa aa aaa|", |
| 153 | \ " aaa aa aa|", |
| 154 | \ "a aaa aa a|", |
| 155 | \ "aa aaa aa |", |
| 156 | \ ] |
| 157 | call assert_equal(expect, lines) |
| 158 | set list& listchars& wrap& |
| 159 | bw! |
| 160 | endfunc |
Bram Moolenaar | 2868668 | 2019-10-24 15:12:37 +0200 | [diff] [blame] | 161 | |
| 162 | " Check that win_lines() works correctly with the number_only parameter=TRUE |
| 163 | " should break early to optimize cost of drawing, but needs to make sure |
| 164 | " that the number column is correctly highlighted. |
| 165 | func Test_scroll_CursorLineNr_update() |
| 166 | CheckScreendump |
| 167 | |
| 168 | let lines =<< trim END |
| 169 | hi CursorLineNr ctermfg=73 ctermbg=236 |
| 170 | set nu rnu cursorline cursorlineopt=number |
| 171 | exe ":norm! o\<esc>110ia\<esc>" |
| 172 | END |
| 173 | let filename = 'Xdrawscreen' |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 174 | call writefile(lines, filename, 'D') |
Bram Moolenaar | 2868668 | 2019-10-24 15:12:37 +0200 | [diff] [blame] | 175 | let buf = RunVimInTerminal('-S '.filename, #{rows: 5, cols: 50}) |
| 176 | call term_sendkeys(buf, "k") |
Bram Moolenaar | 2868668 | 2019-10-24 15:12:37 +0200 | [diff] [blame] | 177 | call VerifyScreenDump(buf, 'Test_winline_rnu', {}) |
| 178 | |
| 179 | " clean up |
| 180 | call StopVimInTerminal(buf) |
Bram Moolenaar | 2868668 | 2019-10-24 15:12:37 +0200 | [diff] [blame] | 181 | endfunc |
Bram Moolenaar | 0efd1bd | 2019-12-11 19:00:04 +0100 | [diff] [blame] | 182 | |
| 183 | " check a long file name does not result in the hit-enter prompt |
| 184 | func Test_edit_long_file_name() |
| 185 | CheckScreendump |
| 186 | |
Bram Moolenaar | 6e43b30 | 2019-12-14 17:53:27 +0100 | [diff] [blame] | 187 | let longName = 'x'->repeat(min([&columns, 255])) |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 188 | call writefile([], longName, 'D') |
Bram Moolenaar | 0efd1bd | 2019-12-11 19:00:04 +0100 | [diff] [blame] | 189 | let buf = RunVimInTerminal('-N -u NONE ' .. longName, #{rows: 8}) |
| 190 | |
| 191 | call VerifyScreenDump(buf, 'Test_long_file_name_1', {}) |
| 192 | |
Bram Moolenaar | 0efd1bd | 2019-12-11 19:00:04 +0100 | [diff] [blame] | 193 | " clean up |
| 194 | call StopVimInTerminal(buf) |
Bram Moolenaar | 0efd1bd | 2019-12-11 19:00:04 +0100 | [diff] [blame] | 195 | endfunc |
| 196 | |
Bram Moolenaar | 32ee627 | 2020-06-10 14:16:49 +0200 | [diff] [blame] | 197 | func Test_unprintable_fileformats() |
| 198 | CheckScreendump |
| 199 | |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 200 | call writefile(["unix\r", "two"], 'Xunix.txt', 'D') |
| 201 | call writefile(["mac\r", "two"], 'Xmac.txt', 'D') |
Bram Moolenaar | 32ee627 | 2020-06-10 14:16:49 +0200 | [diff] [blame] | 202 | let lines =<< trim END |
| 203 | edit Xunix.txt |
| 204 | split Xmac.txt |
| 205 | edit ++ff=mac |
| 206 | END |
| 207 | let filename = 'Xunprintable' |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 208 | call writefile(lines, filename, 'D') |
Bram Moolenaar | 32ee627 | 2020-06-10 14:16:49 +0200 | [diff] [blame] | 209 | let buf = RunVimInTerminal('-S '.filename, #{rows: 9, cols: 50}) |
| 210 | call VerifyScreenDump(buf, 'Test_display_unprintable_01', {}) |
| 211 | call term_sendkeys(buf, "\<C-W>\<C-W>\<C-L>") |
| 212 | call VerifyScreenDump(buf, 'Test_display_unprintable_02', {}) |
| 213 | |
| 214 | " clean up |
| 215 | call StopVimInTerminal(buf) |
Bram Moolenaar | 32ee627 | 2020-06-10 14:16:49 +0200 | [diff] [blame] | 216 | endfunc |
Bram Moolenaar | f8992d4 | 2020-08-01 19:14:13 +0200 | [diff] [blame] | 217 | |
| 218 | " Test for scrolling that modifies buffer during visual block |
| 219 | func Test_visual_block_scroll() |
| 220 | CheckScreendump |
| 221 | |
| 222 | let lines =<< trim END |
| 223 | source $VIMRUNTIME/plugin/matchparen.vim |
| 224 | set scrolloff=1 |
| 225 | call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}']) |
| 226 | call cursor(5, 1) |
| 227 | END |
| 228 | |
| 229 | let filename = 'Xvisualblockmodifiedscroll' |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 230 | call writefile(lines, filename, 'D') |
Bram Moolenaar | f8992d4 | 2020-08-01 19:14:13 +0200 | [diff] [blame] | 231 | |
| 232 | let buf = RunVimInTerminal('-S '.filename, #{rows: 7}) |
| 233 | call term_sendkeys(buf, "V\<C-D>\<C-D>") |
| 234 | |
| 235 | call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {}) |
| 236 | |
| 237 | call StopVimInTerminal(buf) |
Bram Moolenaar | f8992d4 | 2020-08-01 19:14:13 +0200 | [diff] [blame] | 238 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 239 | |
Bram Moolenaar | 28a896f | 2022-11-28 22:21:12 +0000 | [diff] [blame] | 240 | " Test for clearing paren highlight when switching buffers |
| 241 | func Test_matchparen_clear_highlight() |
| 242 | CheckScreendump |
| 243 | |
| 244 | let lines =<< trim END |
| 245 | source $VIMRUNTIME/plugin/matchparen.vim |
| 246 | set hidden |
| 247 | call setline(1, ['()']) |
| 248 | normal 0 |
| 249 | |
| 250 | func OtherBuffer() |
| 251 | enew |
| 252 | exe "normal iaa\<Esc>0" |
| 253 | endfunc |
| 254 | END |
| 255 | call writefile(lines, 'XMatchparenClear', 'D') |
| 256 | let buf = RunVimInTerminal('-S XMatchparenClear', #{rows: 5}) |
| 257 | call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {}) |
| 258 | |
| 259 | call term_sendkeys(buf, ":call OtherBuffer()\<CR>:\<Esc>") |
| 260 | call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {}) |
| 261 | |
| 262 | call term_sendkeys(buf, "\<C-^>:\<Esc>") |
| 263 | call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {}) |
| 264 | |
| 265 | call term_sendkeys(buf, "\<C-^>:\<Esc>") |
| 266 | call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {}) |
| 267 | |
| 268 | call StopVimInTerminal(buf) |
| 269 | endfunc |
| 270 | |
Bram Moolenaar | 9dc1917 | 2020-08-19 20:19:48 +0200 | [diff] [blame] | 271 | func Test_display_scroll_at_topline() |
| 272 | CheckScreendump |
| 273 | |
| 274 | let buf = RunVimInTerminal('', #{cols: 20}) |
| 275 | call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\<CR>") |
Bram Moolenaar | 733d259 | 2020-08-20 18:59:06 +0200 | [diff] [blame] | 276 | call TermWait(buf) |
Bram Moolenaar | 9dc1917 | 2020-08-19 20:19:48 +0200 | [diff] [blame] | 277 | call term_sendkeys(buf, "O\<Esc>") |
| 278 | call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4}) |
| 279 | |
| 280 | call StopVimInTerminal(buf) |
| 281 | endfunc |
| 282 | |
Bram Moolenaar | abb6fbd | 2022-03-25 15:42:27 +0000 | [diff] [blame] | 283 | func Test_display_scroll_update_visual() |
| 284 | CheckScreendump |
| 285 | |
| 286 | let lines =<< trim END |
| 287 | set scrolloff=0 |
| 288 | call setline(1, repeat(['foo'], 10)) |
| 289 | call sign_define('foo', { 'text': '>' }) |
| 290 | call sign_place(1, 'bar', 'foo', bufnr(), { 'lnum': 2 }) |
| 291 | call sign_place(2, 'bar', 'foo', bufnr(), { 'lnum': 1 }) |
| 292 | autocmd CursorMoved * if getcurpos()[1] == 2 | call sign_unplace('bar', { 'id': 1 }) | endif |
| 293 | END |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 294 | call writefile(lines, 'XupdateVisual.vim', 'D') |
Bram Moolenaar | abb6fbd | 2022-03-25 15:42:27 +0000 | [diff] [blame] | 295 | |
| 296 | let buf = RunVimInTerminal('-S XupdateVisual.vim', #{rows: 8, cols: 60}) |
| 297 | call term_sendkeys(buf, "VG7kk") |
| 298 | call VerifyScreenDump(buf, 'Test_display_scroll_update_visual', {}) |
| 299 | |
| 300 | call StopVimInTerminal(buf) |
Bram Moolenaar | abb6fbd | 2022-03-25 15:42:27 +0000 | [diff] [blame] | 301 | endfunc |
| 302 | |
Bram Moolenaar | a98f8a2 | 2021-02-13 18:24:23 +0100 | [diff] [blame] | 303 | " Test for 'eob' (EndOfBuffer) item in 'fillchars' |
| 304 | func Test_eob_fillchars() |
| 305 | " default value |
| 306 | call assert_match('eob:\~', &fillchars) |
| 307 | " invalid values |
| 308 | call assert_fails(':set fillchars=eob:', 'E474:') |
| 309 | call assert_fails(':set fillchars=eob:xy', 'E474:') |
| 310 | call assert_fails(':set fillchars=eob:\255', 'E474:') |
| 311 | call assert_fails(':set fillchars=eob:<ff>', 'E474:') |
zeertzjq | 60618c8 | 2021-12-18 15:32:46 +0000 | [diff] [blame] | 312 | call assert_fails(":set fillchars=eob:\x01", 'E474:') |
| 313 | call assert_fails(':set fillchars=eob:\\x01', 'E474:') |
Bram Moolenaar | a98f8a2 | 2021-02-13 18:24:23 +0100 | [diff] [blame] | 314 | " default is ~ |
| 315 | new |
Bram Moolenaar | 2cec027 | 2021-03-22 17:30:47 +0100 | [diff] [blame] | 316 | redraw |
Bram Moolenaar | a98f8a2 | 2021-02-13 18:24:23 +0100 | [diff] [blame] | 317 | call assert_equal('~', Screenline(2)) |
| 318 | set fillchars=eob:+ |
Bram Moolenaar | 2cec027 | 2021-03-22 17:30:47 +0100 | [diff] [blame] | 319 | redraw |
Bram Moolenaar | a98f8a2 | 2021-02-13 18:24:23 +0100 | [diff] [blame] | 320 | call assert_equal('+', Screenline(2)) |
| 321 | set fillchars=eob:\ |
Bram Moolenaar | 2cec027 | 2021-03-22 17:30:47 +0100 | [diff] [blame] | 322 | redraw |
Bram Moolenaar | a98f8a2 | 2021-02-13 18:24:23 +0100 | [diff] [blame] | 323 | call assert_equal(' ', nr2char(screenchar(2, 1))) |
| 324 | set fillchars& |
| 325 | close |
| 326 | endfunc |
| 327 | |
Bram Moolenaar | 3aca5a6 | 2021-02-17 13:14:07 +0100 | [diff] [blame] | 328 | " Test for 'foldopen', 'foldclose' and 'foldsep' in 'fillchars' |
| 329 | func Test_fold_fillchars() |
| 330 | new |
| 331 | set fdc=2 foldenable foldmethod=manual |
| 332 | call setline(1, ['one', 'two', 'three', 'four', 'five']) |
| 333 | 2,4fold |
| 334 | " First check for the default setting for a closed fold |
| 335 | let lines = ScreenLines([1, 3], 8) |
| 336 | let expected = [ |
| 337 | \ ' one ', |
| 338 | \ '+ +-- 3', |
| 339 | \ ' five ' |
| 340 | \ ] |
| 341 | call assert_equal(expected, lines) |
| 342 | normal 2Gzo |
| 343 | " check the characters for an open fold |
| 344 | let lines = ScreenLines([1, 5], 8) |
| 345 | let expected = [ |
| 346 | \ ' one ', |
| 347 | \ '- two ', |
| 348 | \ '| three ', |
| 349 | \ '| four ', |
| 350 | \ ' five ' |
| 351 | \ ] |
| 352 | call assert_equal(expected, lines) |
| 353 | |
| 354 | " change the setting |
| 355 | set fillchars=vert:\|,fold:-,eob:~,foldopen:[,foldclose:],foldsep:- |
| 356 | |
| 357 | " check the characters for an open fold |
| 358 | let lines = ScreenLines([1, 5], 8) |
| 359 | let expected = [ |
| 360 | \ ' one ', |
| 361 | \ '[ two ', |
| 362 | \ '- three ', |
| 363 | \ '- four ', |
| 364 | \ ' five ' |
| 365 | \ ] |
| 366 | call assert_equal(expected, lines) |
| 367 | |
| 368 | " check the characters for a closed fold |
| 369 | normal 2Gzc |
| 370 | let lines = ScreenLines([1, 3], 8) |
| 371 | let expected = [ |
| 372 | \ ' one ', |
| 373 | \ '] +-- 3', |
| 374 | \ ' five ' |
| 375 | \ ] |
| 376 | call assert_equal(expected, lines) |
| 377 | |
| 378 | %bw! |
| 379 | set fillchars& fdc& foldmethod& foldenable& |
| 380 | endfunc |
| 381 | |
Bram Moolenaar | 96ba25a | 2022-07-04 17:34:33 +0100 | [diff] [blame] | 382 | func Test_local_fillchars() |
| 383 | CheckScreendump |
| 384 | |
| 385 | let lines =<< trim END |
| 386 | call setline(1, ['window 1']->repeat(3)) |
| 387 | setlocal fillchars=stl:1,stlnc:a,vert:=,eob:x |
| 388 | vnew |
| 389 | call setline(1, ['window 2']->repeat(3)) |
| 390 | setlocal fillchars=stl:2,stlnc:b,vert:+,eob:y |
| 391 | new |
| 392 | wincmd J |
| 393 | call setline(1, ['window 3']->repeat(3)) |
| 394 | setlocal fillchars=stl:3,stlnc:c,vert:<,eob:z |
| 395 | vnew |
| 396 | call setline(1, ['window 4']->repeat(3)) |
| 397 | setlocal fillchars=stl:4,stlnc:d,vert:>,eob:o |
| 398 | END |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 399 | call writefile(lines, 'Xdisplayfillchars', 'D') |
Bram Moolenaar | 96ba25a | 2022-07-04 17:34:33 +0100 | [diff] [blame] | 400 | let buf = RunVimInTerminal('-S Xdisplayfillchars', #{rows: 12}) |
| 401 | call VerifyScreenDump(buf, 'Test_display_fillchars_1', {}) |
| 402 | |
| 403 | call term_sendkeys(buf, ":wincmd k\r") |
| 404 | call VerifyScreenDump(buf, 'Test_display_fillchars_2', {}) |
| 405 | |
| 406 | call StopVimInTerminal(buf) |
Bram Moolenaar | 96ba25a | 2022-07-04 17:34:33 +0100 | [diff] [blame] | 407 | endfunc |
| 408 | |
Bram Moolenaar | a06e345 | 2021-05-29 17:56:37 +0200 | [diff] [blame] | 409 | func Test_display_linebreak_breakat() |
| 410 | new |
| 411 | vert resize 25 |
| 412 | let _breakat = &breakat |
| 413 | setl signcolumn=yes linebreak breakat=) showbreak=+\ |
| 414 | call setline(1, repeat('x', winwidth(0) - 2) .. ')abc') |
| 415 | let lines = ScreenLines([1, 2], 25) |
| 416 | let expected = [ |
| 417 | \ ' xxxxxxxxxxxxxxxxxxxxxxx', |
| 418 | \ ' + )abc ' |
| 419 | \ ] |
| 420 | call assert_equal(expected, lines) |
| 421 | %bw! |
| 422 | let &breakat=_breakat |
| 423 | endfunc |
| 424 | |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 425 | func Run_Test_display_lastline(euro) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 426 | let lines =<< trim END |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 427 | call setline(1, ['aaa', 'b'->repeat(200)]) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 428 | set display=truncate |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 429 | |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 430 | vsplit |
| 431 | 100wincmd < |
| 432 | END |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 433 | if a:euro != '' |
| 434 | let lines[2] = 'set fillchars=vert:\|,lastline:€' |
| 435 | endif |
Bram Moolenaar | 5917341 | 2022-09-20 22:01:33 +0100 | [diff] [blame] | 436 | call writefile(lines, 'XdispLastline', 'D') |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 437 | let buf = RunVimInTerminal('-S XdispLastline', #{rows: 10}) |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 438 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}1', {}) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 439 | |
| 440 | call term_sendkeys(buf, ":set display=lastline\<CR>") |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 441 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}2', {}) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 442 | |
| 443 | call term_sendkeys(buf, ":100wincmd >\<CR>") |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 444 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}3', {}) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 445 | |
| 446 | call term_sendkeys(buf, ":set display=truncate\<CR>") |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 447 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}4', {}) |
| 448 | |
| 449 | call term_sendkeys(buf, ":close\<CR>") |
| 450 | call term_sendkeys(buf, ":3split\<CR>") |
| 451 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}5', {}) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 452 | |
zeertzjq | 18b3500 | 2022-10-04 20:35:37 +0100 | [diff] [blame] | 453 | call term_sendkeys(buf, ":close\<CR>") |
| 454 | call term_sendkeys(buf, ":2vsplit\<CR>") |
| 455 | call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}6', {}) |
| 456 | |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 457 | call StopVimInTerminal(buf) |
Bram Moolenaar | cee9c84 | 2022-04-09 12:40:13 +0100 | [diff] [blame] | 458 | endfunc |
| 459 | |
Bram Moolenaar | 4ba5f1d | 2022-10-04 14:36:29 +0100 | [diff] [blame] | 460 | func Test_display_lastline() |
| 461 | CheckScreendump |
| 462 | |
| 463 | call Run_Test_display_lastline('') |
| 464 | call Run_Test_display_lastline('euro_') |
| 465 | |
| 466 | call assert_fails(':set fillchars=lastline:', 'E474:') |
| 467 | call assert_fails(':set fillchars=lastline:〇', 'E474:') |
| 468 | endfunc |
| 469 | |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 470 | func Test_display_long_lastline() |
| 471 | CheckScreendump |
| 472 | |
| 473 | let lines =<< trim END |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 474 | set display=lastline smoothscroll scrolloff=0 |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 475 | call setline(1, [ |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 476 | \'aaaaa'->repeat(150), |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 477 | \'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7) |
| 478 | \]) |
| 479 | END |
| 480 | |
| 481 | call writefile(lines, 'XdispLongline', 'D') |
| 482 | let buf = RunVimInTerminal('-S XdispLongline', #{rows: 14, cols: 35}) |
| 483 | |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 484 | call term_sendkeys(buf, "736|") |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 485 | call VerifyScreenDump(buf, 'Test_display_long_line_1', {}) |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 486 | |
| 487 | " The correct part of the last line is moved into view. |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 488 | call term_sendkeys(buf, "D") |
| 489 | call VerifyScreenDump(buf, 'Test_display_long_line_2', {}) |
| 490 | |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 491 | " "w_skipcol" does not change because the topline is still long enough |
| 492 | " to maintain the current skipcol. |
| 493 | call term_sendkeys(buf, "g04l11gkD") |
| 494 | call VerifyScreenDump(buf, 'Test_display_long_line_3', {}) |
| 495 | |
| 496 | " "w_skipcol" is reset to bring the entire topline into view because |
| 497 | " the line length is now smaller than the current skipcol + marker. |
| 498 | call term_sendkeys(buf, "x") |
| 499 | call VerifyScreenDump(buf, 'Test_display_long_line_4', {}) |
| 500 | |
Luuk van Baal | 5b10a14 | 2023-04-30 19:15:30 +0100 | [diff] [blame] | 501 | call StopVimInTerminal(buf) |
| 502 | endfunc |
Bram Moolenaar | a06e345 | 2021-05-29 17:56:37 +0200 | [diff] [blame] | 503 | |
Luuk van Baal | 6c01868 | 2023-05-11 18:38:14 +0100 | [diff] [blame] | 504 | " Moving the cursor to a line that doesn't fit in the window should show |
| 505 | " correctly. |
| 506 | func Test_display_cursor_long_line() |
| 507 | CheckScreendump |
| 508 | |
| 509 | let lines =<< trim END |
| 510 | call setline(1, ['a', 'bbbbb '->repeat(100), 'c']) |
| 511 | norm $j |
| 512 | END |
| 513 | |
| 514 | call writefile(lines, 'XdispCursorLongline', 'D') |
| 515 | let buf = RunVimInTerminal('-S XdispCursorLongline', #{rows: 8}) |
| 516 | |
| 517 | call VerifyScreenDump(buf, 'Test_display_cursor_long_line', {}) |
| 518 | |
| 519 | call StopVimInTerminal(buf) |
| 520 | endfunc |
| 521 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 522 | " vim: shiftwidth=2 sts=2 expandtab |