blob: 5f597f133b3021f2016f7fe3e5186e9f30ef1b55 [file] [log] [blame]
Bram Moolenaar62706602016-12-09 19:28:48 +01001" Test for displaying stuff
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +02002
Bram Moolenaar62706602016-12-09 19:28:48 +01003if !has('gui_running') && has('unix')
4 set term=ansi
5endif
6
Christian Brabandteb380b92025-07-07 20:53:55 +02007source util/screendump.vim
Bram Moolenaar62706602016-12-09 19:28:48 +01008
Bram Moolenaar1e115362019-01-09 23:01:02 +01009func Test_display_foldcolumn()
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020010 CheckFeature folding
11
Bram Moolenaar62706602016-12-09 19:28:48 +010012 new
13 vnew
14 vert resize 25
Bram Moolenaar70892372016-12-09 19:51:49 +010015 call assert_equal(25, winwidth(winnr()))
16 set isprint=@
Bram Moolenaar62706602016-12-09 19:28:48 +010017
18 1put='e more noise blah blah‚ more stuff here'
19
Bram Moolenaarc6cd8402017-03-29 14:40:47 +020020 let expect = [
21 \ "e more noise blah blah<82",
22 \ "> more stuff here "
23 \ ]
Bram Moolenaar62706602016-12-09 19:28:48 +010024
25 call cursor(2, 1)
26 norm! zt
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020027 let lines = ScreenLines([1,2], winwidth(0))
Bram Moolenaarc6cd8402017-03-29 14:40:47 +020028 call assert_equal(expect, lines)
Bram Moolenaar62706602016-12-09 19:28:48 +010029 set fdc=2
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020030 let lines = ScreenLines([1,2], winwidth(0))
Bram Moolenaarc6cd8402017-03-29 14:40:47 +020031 let expect = [
32 \ " e more noise blah blah<",
33 \ " 82> more stuff here "
34 \ ]
35 call assert_equal(expect, lines)
Bram Moolenaar62706602016-12-09 19:28:48 +010036
37 quit!
38 quit!
Bram Moolenaarc6cd8402017-03-29 14:40:47 +020039endfunc
40
Bram Moolenaar1e115362019-01-09 23:01:02 +010041func Test_display_foldtext_mbyte()
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020042 CheckFeature folding
43
Bram Moolenaarc6cd8402017-03-29 14:40:47 +020044 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 Moolenaar8da1e6c2017-03-29 20:38:59 +020056
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 Moolenaarc6cd8402017-03-29 14:40:47 +020066 set foldtext& fillchars& foldmethod& fdc&
67 bw!
68endfunc
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020069
70" check that win_ins_lines() and win_del_lines() work when t_cs is empty.
71func 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 Moolenaar59173412022-09-20 22:01:33 +010079 call writefile(lines, 'Xtestscroll', 'D')
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020080 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 Moolenaar7cc53512019-08-03 23:30:21 +020090 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 Moolenaar3c8ee622019-08-03 22:55:50 +0200101 " clean up
102 call StopVimInTerminal(buf)
Bram Moolenaar3c8ee622019-08-03 22:55:50 +0200103endfunc
Bram Moolenaarbffba7f2019-09-20 17:00:17 +0200104
105func 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 Moolenaar297164c2022-10-15 14:24:29 +0100144 \ "<aaa aaa a|",
Bram Moolenaarbffba7f2019-09-20 17:00:17 +0200145 \ "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!
158endfunc
Bram Moolenaar28686682019-10-24 15:12:37 +0200159
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.
163func 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 Moolenaar59173412022-09-20 22:01:33 +0100172 call writefile(lines, filename, 'D')
Bram Moolenaar28686682019-10-24 15:12:37 +0200173 let buf = RunVimInTerminal('-S '.filename, #{rows: 5, cols: 50})
174 call term_sendkeys(buf, "k")
Bram Moolenaar28686682019-10-24 15:12:37 +0200175 call VerifyScreenDump(buf, 'Test_winline_rnu', {})
176
177 " clean up
178 call StopVimInTerminal(buf)
Bram Moolenaar28686682019-10-24 15:12:37 +0200179endfunc
Bram Moolenaar0efd1bd2019-12-11 19:00:04 +0100180
181" check a long file name does not result in the hit-enter prompt
182func Test_edit_long_file_name()
183 CheckScreendump
184
Bram Moolenaar6e43b302019-12-14 17:53:27 +0100185 let longName = 'x'->repeat(min([&columns, 255]))
Bram Moolenaar59173412022-09-20 22:01:33 +0100186 call writefile([], longName, 'D')
Bram Moolenaar0efd1bd2019-12-11 19:00:04 +0100187 let buf = RunVimInTerminal('-N -u NONE ' .. longName, #{rows: 8})
188
189 call VerifyScreenDump(buf, 'Test_long_file_name_1', {})
190
Bram Moolenaar0efd1bd2019-12-11 19:00:04 +0100191 " clean up
192 call StopVimInTerminal(buf)
Bram Moolenaar0efd1bd2019-12-11 19:00:04 +0100193endfunc
194
Bram Moolenaar32ee6272020-06-10 14:16:49 +0200195func Test_unprintable_fileformats()
196 CheckScreendump
197
Bram Moolenaar59173412022-09-20 22:01:33 +0100198 call writefile(["unix\r", "two"], 'Xunix.txt', 'D')
199 call writefile(["mac\r", "two"], 'Xmac.txt', 'D')
Bram Moolenaar32ee6272020-06-10 14:16:49 +0200200 let lines =<< trim END
201 edit Xunix.txt
202 split Xmac.txt
203 edit ++ff=mac
204 END
205 let filename = 'Xunprintable'
Bram Moolenaar59173412022-09-20 22:01:33 +0100206 call writefile(lines, filename, 'D')
Bram Moolenaar32ee6272020-06-10 14:16:49 +0200207 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 Moolenaar32ee6272020-06-10 14:16:49 +0200214endfunc
Bram Moolenaarf8992d42020-08-01 19:14:13 +0200215
Bram Moolenaar9dc19172020-08-19 20:19:48 +0200216func 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 Moolenaar733d2592020-08-20 18:59:06 +0200221 call TermWait(buf)
Bram Moolenaar9dc19172020-08-19 20:19:48 +0200222 call term_sendkeys(buf, "O\<Esc>")
223 call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4})
224
225 call StopVimInTerminal(buf)
226endfunc
227
Bram Moolenaarabb6fbd2022-03-25 15:42:27 +0000228func 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 Moolenaar59173412022-09-20 22:01:33 +0100239 call writefile(lines, 'XupdateVisual.vim', 'D')
Bram Moolenaarabb6fbd2022-03-25 15:42:27 +0000240
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 Moolenaarabb6fbd2022-03-25 15:42:27 +0000246endfunc
247
Bram Moolenaara98f8a22021-02-13 18:24:23 +0100248" Test for 'eob' (EndOfBuffer) item in 'fillchars'
249func Test_eob_fillchars()
250 " default value
251 call assert_match('eob:\~', &fillchars)
252 " invalid values
zeertzjq6a8d2e12024-01-17 20:54:49 +0100253 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 Moolenaara98f8a22021-02-13 18:24:23 +0100259 " default is ~
260 new
Bram Moolenaar2cec0272021-03-22 17:30:47 +0100261 redraw
Bram Moolenaara98f8a22021-02-13 18:24:23 +0100262 call assert_equal('~', Screenline(2))
263 set fillchars=eob:+
Bram Moolenaar2cec0272021-03-22 17:30:47 +0100264 redraw
Bram Moolenaara98f8a22021-02-13 18:24:23 +0100265 call assert_equal('+', Screenline(2))
266 set fillchars=eob:\
Bram Moolenaar2cec0272021-03-22 17:30:47 +0100267 redraw
Bram Moolenaara98f8a22021-02-13 18:24:23 +0100268 call assert_equal(' ', nr2char(screenchar(2, 1)))
269 set fillchars&
270 close
271endfunc
272
Bram Moolenaar3aca5a62021-02-17 13:14:07 +0100273" Test for 'foldopen', 'foldclose' and 'foldsep' in 'fillchars'
274func 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&
325endfunc
326
Bram Moolenaar96ba25a2022-07-04 17:34:33 +0100327func 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 Moolenaar59173412022-09-20 22:01:33 +0100344 call writefile(lines, 'Xdisplayfillchars', 'D')
Bram Moolenaar96ba25a2022-07-04 17:34:33 +0100345 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 Moolenaar96ba25a2022-07-04 17:34:33 +0100352endfunc
353
Bram Moolenaara06e3452021-05-29 17:56:37 +0200354func Test_display_linebreak_breakat()
355 new
356 vert resize 25
357 let _breakat = &breakat
zeertzjq1d3e0e82023-08-28 21:20:16 +0200358 setl signcolumn=yes linebreak breakat=) showbreak=++
Bram Moolenaara06e3452021-05-29 17:56:37 +0200359 call setline(1, repeat('x', winwidth(0) - 2) .. ')abc')
360 let lines = ScreenLines([1, 2], 25)
361 let expected = [
362 \ ' xxxxxxxxxxxxxxxxxxxxxxx',
zeertzjq1d3e0e82023-08-28 21:20:16 +0200363 \ ' ++)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 Moolenaara06e3452021-05-29 17:56:37 +0200371 \ ]
372 call assert_equal(expected, lines)
373 %bw!
374 let &breakat=_breakat
375endfunc
376
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100377func Run_Test_display_lastline(euro)
Drew Vogelea67ba72025-05-07 22:05:17 +0200378 CheckScreendump
379
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100380 let lines =<< trim END
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100381 call setline(1, ['aaa', 'b'->repeat(200)])
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100382 set display=truncate
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100383
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100384 vsplit
385 100wincmd <
386 END
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100387 if a:euro != ''
388 let lines[2] = 'set fillchars=vert:\|,lastline:€'
389 endif
Bram Moolenaar59173412022-09-20 22:01:33 +0100390 call writefile(lines, 'XdispLastline', 'D')
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100391 let buf = RunVimInTerminal('-S XdispLastline', #{rows: 10})
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100392 call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}1', {})
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100393
394 call term_sendkeys(buf, ":set display=lastline\<CR>")
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100395 call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}2', {})
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100396
397 call term_sendkeys(buf, ":100wincmd >\<CR>")
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100398 call VerifyScreenDump(buf, $'Test_display_lastline_{a:euro}3', {})
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100399
400 call term_sendkeys(buf, ":set display=truncate\<CR>")
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100401 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 Moolenaarcee9c842022-04-09 12:40:13 +0100406
zeertzjq18b35002022-10-04 20:35:37 +0100407 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 Moolenaarcee9c842022-04-09 12:40:13 +0100411 call StopVimInTerminal(buf)
Bram Moolenaarcee9c842022-04-09 12:40:13 +0100412endfunc
413
zeertzjq6a8d2e12024-01-17 20:54:49 +0100414func Test_display_lastline_dump()
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100415 CheckScreendump
416
417 call Run_Test_display_lastline('')
418 call Run_Test_display_lastline('euro_')
zeertzjq6a8d2e12024-01-17 20:54:49 +0100419endfunc
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100420
zeertzjq6a8d2e12024-01-17 20:54:49 +0100421func Test_display_lastline_fails()
422 call assert_fails(':set fillchars=lastline:', 'E1511:')
423 call assert_fails(':set fillchars=lastline:〇', 'E1512:')
Bram Moolenaar4ba5f1d2022-10-04 14:36:29 +0100424endfunc
425
Luuk van Baal5b10a142023-04-30 19:15:30 +0100426func Test_display_long_lastline()
427 CheckScreendump
428
429 let lines =<< trim END
Luuk van Baal5d01f862023-05-11 19:24:20 +0100430 set display=lastline smoothscroll scrolloff=0
Luuk van Baal5b10a142023-04-30 19:15:30 +0100431 call setline(1, [
Luuk van Baal5d01f862023-05-11 19:24:20 +0100432 \'aaaaa'->repeat(150),
Luuk van Baal5b10a142023-04-30 19:15:30 +0100433 \'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 Baal5d01f862023-05-11 19:24:20 +0100440 call term_sendkeys(buf, "736|")
Luuk van Baal5b10a142023-04-30 19:15:30 +0100441 call VerifyScreenDump(buf, 'Test_display_long_line_1', {})
Luuk van Baal5d01f862023-05-11 19:24:20 +0100442
443 " The correct part of the last line is moved into view.
Luuk van Baal5b10a142023-04-30 19:15:30 +0100444 call term_sendkeys(buf, "D")
445 call VerifyScreenDump(buf, 'Test_display_long_line_2', {})
446
Luuk van Baal5d01f862023-05-11 19:24:20 +0100447 " "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 Baal5b10a142023-04-30 19:15:30 +0100457 call StopVimInTerminal(buf)
458endfunc
Bram Moolenaara06e3452021-05-29 17:56:37 +0200459
Luuk van Baal6c018682023-05-11 18:38:14 +0100460" Moving the cursor to a line that doesn't fit in the window should show
461" correctly.
462func Test_display_cursor_long_line()
463 CheckScreendump
464
465 let lines =<< trim END
Luuk van Baal798fa762023-05-15 18:17:43 +0100466 call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c'])
Luuk van Baal6c018682023-05-11 18:38:14 +0100467 norm $j
468 END
469
470 call writefile(lines, 'XdispCursorLongline', 'D')
471 let buf = RunVimInTerminal('-S XdispCursorLongline', #{rows: 8})
472
Luuk van Baal798fa762023-05-15 18:17:43 +0100473 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 Baal6c018682023-05-11 18:38:14 +0100489
490 call StopVimInTerminal(buf)
491endfunc
492
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200493" vim: shiftwidth=2 sts=2 expandtab