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