test: decoration provider with wrapped lines (#25404)

This commit is contained in:
zeertzjq 2023-09-28 20:20:25 +08:00 committed by GitHub
parent 1913041518
commit 28ffd96c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -521,6 +521,72 @@ describe('decorations providers', function()
]]}
end)
it('virtual text works with wrapped lines', function()
insert(mulholland)
feed('ggJj3JjJ')
setup_provider [[
local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
local test_ns = api.nvim_create_namespace "mulholland"
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
virt_text = {{string.rep('/', line+1), 'ErrorMsg'}};
virt_text_pos='eol';
ephemeral = true;
})
api.nvim_buf_set_extmark(buf, test_ns, line, 6, {
virt_text = {{string.rep('*', line+1), 'ErrorMsg'}};
virt_text_pos='overlay';
ephemeral = true;
})
api.nvim_buf_set_extmark(buf, test_ns, line, 39, {
virt_text = {{string.rep('!', line+1), 'ErrorMsg'}};
virt_text_win_col=20;
ephemeral = true;
})
api.nvim_buf_set_extmark(buf, test_ns, line, 40, {
virt_text = {{string.rep('?', line+1), 'ErrorMsg'}};
virt_text_win_col=10;
ephemeral = true;
})
api.nvim_buf_set_extmark(buf, test_ns, line, 40, {
virt_text = {{string.rep(';', line+1), 'ErrorMsg'}};
virt_text_pos='overlay';
ephemeral = true;
})
api.nvim_buf_set_extmark(buf, test_ns, line, 40, {
virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}};
virt_text_pos='right_align';
ephemeral = true;
})
end
end
]]
screen:expect{grid=[[
// jus{2:*} to see if th{2:!}re was an accident |
{2:;}n Mulholl{2:?}nd Drive {2:/} +{2: }|
try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b|
{2:;;}fer(&sav{2:??}buf, buf); {2://} +{2: }|
posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf|
{2:;;;}(&save_{2:???}); {2:///} +{2: }|
{1:~ }|
|
]]}
command('setlocal breakindent breakindentopt=shift:2')
screen:expect{grid=[[
// jus{2:*} to see if th{2:!}re was an accident |
{2:;}n Mulho{2:?}land Drive {2:/} +{2: }|
try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b|
{2:;;}fer(&s{2:??}e_buf, buf); {2://} +{2: }|
posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf|
{2:;;;}(&sav{2:???}uf); {2:///} +{2: }|
{1:~ }|
|
]]}
end)
it('can highlight beyond EOL', function()
insert(mulholland)
setup_provider [[