2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2020-10-01 23:10:18 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local exec = n.exec
|
|
|
|
local feed = n.feed
|
|
|
|
local command = n.command
|
2020-10-01 23:10:18 -07:00
|
|
|
|
|
|
|
describe('display', function()
|
2022-03-25 17:52:54 -07:00
|
|
|
before_each(clear)
|
2020-10-01 23:10:18 -07:00
|
|
|
|
2022-10-04 06:52:01 -07:00
|
|
|
-- oldtest: Test_display_scroll_at_topline()
|
2022-04-09 13:50:49 -07:00
|
|
|
it('scroll when modified at topline vim-patch:8.2.1488', function()
|
2022-03-25 17:52:54 -07:00
|
|
|
local screen = Screen.new(20, 4)
|
2020-10-01 23:10:18 -07:00
|
|
|
screen:attach()
|
|
|
|
|
2022-04-09 13:50:49 -07:00
|
|
|
command([[call setline(1, repeat('a', 21))]])
|
2020-10-01 23:10:18 -07:00
|
|
|
feed('O')
|
|
|
|
screen:expect([[
|
|
|
|
^ |
|
|
|
|
aaaaaaaaaaaaaaaaaaaa|
|
|
|
|
a |
|
2024-03-27 02:35:50 -07:00
|
|
|
{5:-- INSERT --} |
|
2020-10-01 23:10:18 -07:00
|
|
|
]])
|
|
|
|
end)
|
2022-03-25 17:52:54 -07:00
|
|
|
|
2022-10-04 06:52:01 -07:00
|
|
|
-- oldtest: Test_display_scroll_update_visual()
|
2022-04-09 13:50:49 -07:00
|
|
|
it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function()
|
2022-03-25 17:52:54 -07:00
|
|
|
local screen = Screen.new(60, 8)
|
|
|
|
screen:attach()
|
|
|
|
|
|
|
|
exec([[
|
|
|
|
set scrolloff=0
|
|
|
|
call setline(1, repeat(['foo'], 10))
|
|
|
|
call sign_define('foo', { 'text': '>' })
|
|
|
|
call sign_place(1, 'bar', 'foo', bufnr(), { 'lnum': 2 })
|
|
|
|
call sign_place(2, 'bar', 'foo', bufnr(), { 'lnum': 1 })
|
|
|
|
autocmd CursorMoved * if getcurpos()[1] == 2 | call sign_unplace('bar', { 'id': 1 }) | endif
|
|
|
|
]])
|
|
|
|
feed('VG7kk')
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{7: }^f{17:oo} |
|
|
|
|
{7: }foo |*6
|
|
|
|
{5:-- VISUAL LINE --} |
|
2022-03-25 17:52:54 -07:00
|
|
|
]])
|
|
|
|
end)
|
2020-10-01 23:10:18 -07:00
|
|
|
|
2022-10-04 06:52:01 -07:00
|
|
|
local function run_test_display_lastline(euro)
|
|
|
|
local screen = Screen.new(75, 10)
|
2022-04-09 13:50:49 -07:00
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
|
|
|
[2] = { bold = true, reverse = true }, -- StatusLine
|
|
|
|
[3] = { reverse = true }, -- StatusLineNC
|
|
|
|
})
|
|
|
|
screen:attach()
|
|
|
|
exec([[
|
2022-10-04 06:52:01 -07:00
|
|
|
call setline(1, ['aaa', 'b'->repeat(200)])
|
2022-04-09 13:50:49 -07:00
|
|
|
set display=truncate
|
2022-10-04 06:52:01 -07:00
|
|
|
|
2022-04-09 13:50:49 -07:00
|
|
|
vsplit
|
|
|
|
100wincmd <
|
|
|
|
]])
|
2022-10-04 06:52:01 -07:00
|
|
|
local fillchar = '@'
|
|
|
|
if euro then
|
|
|
|
command('set fillchars=lastline:€')
|
|
|
|
fillchar = '€'
|
|
|
|
end
|
|
|
|
screen:expect((([[
|
|
|
|
^a│aaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2
|
2022-10-04 06:52:01 -07:00
|
|
|
b│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
|
2023-12-09 05:42:00 -07:00
|
|
|
b│{1:~ }|*3
|
2022-10-04 06:52:01 -07:00
|
|
|
{1:@}│{1:~ }|
|
|
|
|
{2:< }{3:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]]):gsub('@', fillchar)))
|
|
|
|
|
2022-04-09 13:50:49 -07:00
|
|
|
command('set display=lastline')
|
|
|
|
screen:expect_unchanged()
|
2022-10-04 06:52:01 -07:00
|
|
|
|
2022-04-09 13:50:49 -07:00
|
|
|
command('100wincmd >')
|
2022-10-04 06:52:01 -07:00
|
|
|
screen:expect((([[
|
|
|
|
^aaa │a|
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a|*2
|
2022-10-04 06:52:01 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │b|
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│b|*3
|
2022-10-04 06:52:01 -07:00
|
|
|
{1:~ }│{1:@}|
|
|
|
|
{2:[No Name] [+] }{3:<}|
|
|
|
|
|
|
|
|
|
]]):gsub('@', fillchar)))
|
|
|
|
|
2022-04-09 13:50:49 -07:00
|
|
|
command('set display=truncate')
|
|
|
|
screen:expect_unchanged()
|
2022-10-04 06:52:01 -07:00
|
|
|
|
|
|
|
command('close')
|
|
|
|
command('3split')
|
|
|
|
screen:expect((([[
|
|
|
|
^aaa |
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
|
|
|
{1:@@@ }|
|
|
|
|
{2:[No Name] [+] }|
|
|
|
|
aaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2
|
2022-10-04 06:52:01 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
|
|
|
|
{3:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]]):gsub('@', fillchar)))
|
2022-10-04 15:48:40 -07:00
|
|
|
|
|
|
|
command('close')
|
|
|
|
command('2vsplit')
|
|
|
|
screen:expect((([[
|
|
|
|
^aa│aaa |
|
|
|
|
a │bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
|
|
|
bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
|
|
|
bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
|
2023-12-09 05:42:00 -07:00
|
|
|
bb│{1:~ }|*3
|
2022-10-04 15:48:40 -07:00
|
|
|
{1:@@}│{1:~ }|
|
|
|
|
{2:< }{3:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]]):gsub('@', fillchar)))
|
2022-10-04 06:52:01 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
-- oldtest: Test_display_lastline()
|
|
|
|
it('display "lastline" works correctly', function()
|
|
|
|
run_test_display_lastline()
|
|
|
|
end)
|
|
|
|
it('display "lastline" works correctly with multibyte fillchar', function()
|
|
|
|
run_test_display_lastline(true)
|
2022-04-09 13:50:49 -07:00
|
|
|
end)
|
2023-04-30 13:04:35 -07:00
|
|
|
|
2023-05-02 16:21:09 -07:00
|
|
|
-- oldtest: Test_display_long_lastline()
|
2023-05-11 11:29:09 -07:00
|
|
|
it('"lastline" shows correct text when end of wrapped line is deleted', function()
|
2023-04-30 13:04:35 -07:00
|
|
|
local screen = Screen.new(35, 14)
|
|
|
|
screen:attach()
|
|
|
|
exec([[
|
2023-05-11 11:37:49 -07:00
|
|
|
set display=lastline smoothscroll scrolloff=0
|
2023-04-30 13:04:35 -07:00
|
|
|
call setline(1, [
|
2023-05-11 17:17:38 -07:00
|
|
|
\'aaaaa'->repeat(150),
|
2023-04-30 13:04:35 -07:00
|
|
|
\'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7)
|
|
|
|
\])
|
|
|
|
]])
|
2023-05-11 11:37:49 -07:00
|
|
|
feed('736|')
|
2023-04-30 13:04:35 -07:00
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
2023-12-09 05:42:00 -07:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*11
|
2023-05-11 17:17:38 -07:00
|
|
|
^aaaaaaaaaaaaaaa |
|
2023-04-30 13:04:35 -07:00
|
|
|
|
|
|
|
|
]])
|
2023-05-11 11:37:49 -07:00
|
|
|
-- The correct part of the last line is moved into view.
|
2023-04-30 13:04:35 -07:00
|
|
|
feed('D')
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
2023-12-09 05:42:00 -07:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*10
|
2023-05-11 11:37:49 -07:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^a|
|
2024-03-22 03:02:52 -07:00
|
|
|
bbbbb bbbbb bbbbb bbbbb bbbbb bb{1:@@@}|
|
2023-04-30 13:04:35 -07:00
|
|
|
|
|
2023-05-11 11:37:49 -07:00
|
|
|
]])
|
|
|
|
-- "w_skipcol" does not change because the topline is still long enough
|
|
|
|
-- to maintain the current skipcol.
|
|
|
|
feed('g04l11gkD')
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:<<<}^a |
|
2023-05-11 11:37:49 -07:00
|
|
|
bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb|
|
|
|
|
bbbbb ccccc ccccc ccccc ccccc cccc|
|
|
|
|
c ccccc ccccc ddddd ddddd ddddd ddd|
|
|
|
|
dd ddddd ddddd ddddd |
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:~ }|*8
|
2023-05-11 11:37:49 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- "w_skipcol" is reset to bring the entire topline into view because
|
|
|
|
-- the line length is now smaller than the current skipcol + marker.
|
|
|
|
feed('x')
|
|
|
|
screen:expect([[
|
2023-12-09 05:42:00 -07:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*9
|
2023-05-11 11:37:49 -07:00
|
|
|
aa^a |
|
|
|
|
bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb|
|
|
|
|
bbbbb ccccc ccccc ccccc ccccc cccc|
|
2024-03-22 03:02:52 -07:00
|
|
|
c ccccc ccccc ddddd ddddd ddddd {1:@@@}|
|
2023-05-11 11:37:49 -07:00
|
|
|
|
|
2023-04-30 13:04:35 -07:00
|
|
|
]])
|
|
|
|
end)
|
2023-05-11 11:29:09 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_display_cursor_long_line()
|
|
|
|
it("correctly shows line that doesn't fit in the window", function()
|
|
|
|
local screen = Screen.new(75, 8)
|
|
|
|
screen:attach()
|
|
|
|
exec([[
|
2023-05-15 16:56:06 -07:00
|
|
|
call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c'])
|
2023-05-11 11:29:09 -07:00
|
|
|
norm $j
|
|
|
|
]])
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:<<<}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*5
|
2023-05-15 16:56:06 -07:00
|
|
|
b^b |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- FIXME: moving the cursor above the topline does not set w_skipcol
|
|
|
|
-- correctly with cpo+=n and zero scrolloff (curs_columns() extra == 1).
|
|
|
|
exec('set number cpo+=n scrolloff=0')
|
|
|
|
feed('$0')
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{1:<<<}b^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6
|
2023-05-15 16:56:06 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Going to the start of the line with "b" did not set w_skipcol correctly with 'smoothscroll'.
|
|
|
|
exec('set smoothscroll')
|
|
|
|
feed('$b')
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{8: 2 }b ^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6
|
2023-05-15 16:56:06 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
-- Same for "ge".
|
|
|
|
feed('$ge')
|
|
|
|
screen:expect([[
|
2024-03-22 03:02:52 -07:00
|
|
|
{8: 2 }^b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
2023-12-09 05:42:00 -07:00
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6
|
2023-05-11 11:29:09 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2022-04-09 13:50:49 -07:00
|
|
|
end)
|