mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
fix(api): make getting explicit empty hl in virtual text work (#28697)
This commit is contained in:
parent
c1396afa7c
commit
4e5c633ed4
@ -121,7 +121,7 @@ Array virt_text_to_array(VirtText vt, bool hl_name, Arena *arena)
|
||||
Array hl_array = arena_array(arena, i < j ? j - i + 1 : 0);
|
||||
for (; i < j; i++) {
|
||||
int hl_id = kv_A(vt, i).hl_id;
|
||||
if (hl_id > 0) {
|
||||
if (hl_id >= 0) {
|
||||
ADD_C(hl_array, hl_group_name(hl_id, hl_name));
|
||||
}
|
||||
}
|
||||
@ -131,11 +131,11 @@ Array virt_text_to_array(VirtText vt, bool hl_name, Arena *arena)
|
||||
Array chunk = arena_array(arena, 2);
|
||||
ADD_C(chunk, CSTR_AS_OBJ(text));
|
||||
if (hl_array.size > 0) {
|
||||
if (hl_id > 0) {
|
||||
if (hl_id >= 0) {
|
||||
ADD_C(hl_array, hl_group_name(hl_id, hl_name));
|
||||
}
|
||||
ADD_C(chunk, ARRAY_OBJ(hl_array));
|
||||
} else if (hl_id > 0) {
|
||||
} else if (hl_id >= 0) {
|
||||
ADD_C(chunk, hl_group_name(hl_id, hl_name));
|
||||
}
|
||||
ADD_C(chunks, ARRAY_OBJ(chunk));
|
||||
@ -1165,7 +1165,7 @@ VirtText parse_virt_text(Array chunks, Error *err, int *width)
|
||||
|
||||
String str = chunk.items[0].data.string;
|
||||
|
||||
int hl_id = 0;
|
||||
int hl_id = -1;
|
||||
if (chunk.size == 2) {
|
||||
Object hl = chunk.items[1];
|
||||
if (hl.type == kObjectTypeArray) {
|
||||
|
@ -346,7 +346,12 @@ char *next_virt_text_chunk(VirtText vt, size_t *pos, int *attr)
|
||||
for (; text == NULL && *pos < kv_size(vt); (*pos)++) {
|
||||
text = kv_A(vt, *pos).text;
|
||||
int hl_id = kv_A(vt, *pos).hl_id;
|
||||
*attr = hl_combine_attr(*attr, hl_id > 0 ? syn_id2attr(hl_id) : 0);
|
||||
if (hl_id >= 0) {
|
||||
*attr = MAX(*attr, 0);
|
||||
if (hl_id > 0) {
|
||||
*attr = hl_combine_attr(*attr, syn_id2attr(hl_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
typedef struct {
|
||||
char *text;
|
||||
int hl_id;
|
||||
int hl_id; ///< -1 if not specified
|
||||
} VirtTextChunk;
|
||||
|
||||
typedef kvec_t(VirtTextChunk) VirtText;
|
||||
|
@ -1569,7 +1569,7 @@ describe('API/extmarks', function()
|
||||
sign_text = '>>',
|
||||
spell = true,
|
||||
virt_lines = {
|
||||
{ { 'lines', 'Macro' }, { '???' } },
|
||||
{ { 'lines', 'Macro' }, { '???' }, { ';;;', '' } },
|
||||
{ { 'stack', { 'Type', 'Search' } }, { '!!!' } },
|
||||
},
|
||||
virt_lines_above = true,
|
||||
@ -1604,7 +1604,7 @@ describe('API/extmarks', function()
|
||||
sign_text = '>>',
|
||||
spell = true,
|
||||
virt_lines = {
|
||||
{ { 'lines', 'Macro' }, { '???' } },
|
||||
{ { 'lines', 'Macro' }, { '???' }, { ';;;', '' } },
|
||||
{ { 'stack', { 'Type', 'Search' } }, { '!!!' } },
|
||||
},
|
||||
virt_lines_above = true,
|
||||
|
@ -2407,6 +2407,7 @@ describe('float window', function()
|
||||
|
||||
command('hi B0 guibg=Red guifg=Black')
|
||||
command('hi B1 guifg=White')
|
||||
|
||||
api.nvim_win_set_config(win, {
|
||||
title = {{"🦄"}, {"BB", {"B0", "B1"}}}, title_pos = "right",
|
||||
footer= {{"🦄"}, {"BB", {"B0", "B1"}}}, footer_pos = "right",
|
||||
@ -2443,6 +2444,47 @@ describe('float window', function()
|
||||
|
|
||||
]]}
|
||||
end
|
||||
eq({{"🦄"}, {"BB", {"B0", "B1"}}}, api.nvim_win_get_config(win).title)
|
||||
eq({{"🦄"}, {"BB", {"B0", "B1"}}}, api.nvim_win_get_config(win).footer)
|
||||
|
||||
api.nvim_win_set_config(win, {
|
||||
title = {{"🦄", ""}, {"BB", {"B0", "B1", ""}}}, title_pos = "left",
|
||||
footer= {{"🦄", ""}, {"BB", {"B0", "B1", ""}}}, footer_pos = "left",
|
||||
})
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|*6
|
||||
[3:----------------------------------------]|
|
||||
## grid 2
|
||||
^ |
|
||||
{0:~ }|*5
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{5:╔}🦄{7:BB}{5:═════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚}🦄{7:BB}{5:═════╝}|
|
||||
]], float_pos={
|
||||
[4] = { 1001, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔}🦄{7:BB}{5:═════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚}🦄{7:BB}{5:═════╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
eq({{"🦄", ""}, {"BB", {"B0", "B1", ""}}}, api.nvim_win_get_config(win).title)
|
||||
eq({{"🦄", ""}, {"BB", {"B0", "B1", ""}}}, api.nvim_win_get_config(win).footer)
|
||||
end)
|
||||
|
||||
it('terminates border on edge of viewport when window extends past viewport', function()
|
||||
|
Loading…
Reference in New Issue
Block a user