mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(decor): don't use separate DecorSignHighlight for url (#30096)
This commit is contained in:
@ -687,6 +687,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
|||||||
|
|
||||||
if (HAS_KEY(opts, set_extmark, url)) {
|
if (HAS_KEY(opts, set_extmark, url)) {
|
||||||
url = string_to_cstr(opts->url);
|
url = string_to_cstr(opts->url);
|
||||||
|
has_hl = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->ui_watched) {
|
if (opts->ui_watched) {
|
||||||
@ -758,13 +759,9 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
|||||||
if (kv_size(virt_lines.data.virt_lines)) {
|
if (kv_size(virt_lines.data.virt_lines)) {
|
||||||
decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_lines, NULL), true);
|
decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_lines, NULL), true);
|
||||||
}
|
}
|
||||||
if (url != NULL) {
|
|
||||||
DecorSignHighlight sh = DECOR_SIGN_HIGHLIGHT_INIT;
|
|
||||||
sh.url = url;
|
|
||||||
decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, 0, 0);
|
|
||||||
}
|
|
||||||
if (has_hl) {
|
if (has_hl) {
|
||||||
DecorSignHighlight sh = decor_sh_from_inline(hl);
|
DecorSignHighlight sh = decor_sh_from_inline(hl);
|
||||||
|
sh.url = url;
|
||||||
decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, (uint32_t)ns_id, id);
|
decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, (uint32_t)ns_id, id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -788,12 +785,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t decor_indexed = DECOR_ID_INVALID;
|
uint32_t decor_indexed = DECOR_ID_INVALID;
|
||||||
if (url != NULL) {
|
|
||||||
DecorSignHighlight sh = DECOR_SIGN_HIGHLIGHT_INIT;
|
|
||||||
sh.url = url;
|
|
||||||
sh.next = decor_indexed;
|
|
||||||
decor_indexed = decor_put_sh(sh);
|
|
||||||
}
|
|
||||||
if (sign.flags & kSHIsSign) {
|
if (sign.flags & kSHIsSign) {
|
||||||
sign.next = decor_indexed;
|
sign.next = decor_indexed;
|
||||||
decor_indexed = decor_put_sh(sign);
|
decor_indexed = decor_put_sh(sign);
|
||||||
@ -806,9 +798,11 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
|||||||
}
|
}
|
||||||
|
|
||||||
DecorInline decor = DECOR_INLINE_INIT;
|
DecorInline decor = DECOR_INLINE_INIT;
|
||||||
if (decor_alloc || decor_indexed != DECOR_ID_INVALID || schar_high(hl.conceal_char)) {
|
if (decor_alloc || decor_indexed != DECOR_ID_INVALID || url != NULL
|
||||||
|
|| schar_high(hl.conceal_char)) {
|
||||||
if (has_hl) {
|
if (has_hl) {
|
||||||
DecorSignHighlight sh = decor_sh_from_inline(hl);
|
DecorSignHighlight sh = decor_sh_from_inline(hl);
|
||||||
|
sh.url = url;
|
||||||
sh.next = decor_indexed;
|
sh.next = decor_indexed;
|
||||||
decor_indexed = decor_put_sh(sh);
|
decor_indexed = decor_put_sh(sh);
|
||||||
}
|
}
|
||||||
|
@ -1798,10 +1798,15 @@ describe('API/extmarks', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set a URL', function()
|
it('can set a URL', function()
|
||||||
set_extmark(ns, 1, 0, 0, { url = 'https://example.com', end_col = 3 })
|
local url1 = 'https://example.com'
|
||||||
|
local url2 = 'http://127.0.0.1'
|
||||||
|
set_extmark(ns, 1, 0, 0, { url = url1, end_col = 3 })
|
||||||
|
set_extmark(ns, 2, 0, 3, { url = url2, hl_group = 'Search', end_col = 5 })
|
||||||
local extmarks = get_extmarks(ns, 0, -1, { details = true })
|
local extmarks = get_extmarks(ns, 0, -1, { details = true })
|
||||||
eq(1, #extmarks)
|
eq(2, #extmarks)
|
||||||
eq('https://example.com', extmarks[1][4].url)
|
eq(url1, extmarks[1][4].url)
|
||||||
|
eq(url2, extmarks[2][4].url)
|
||||||
|
eq('Search', extmarks[2][4].hl_group)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('respects priority', function()
|
it('respects priority', function()
|
||||||
|
@ -2341,21 +2341,28 @@ describe('extmark decorations', function()
|
|||||||
it('supports URLs', function()
|
it('supports URLs', function()
|
||||||
insert(example_text)
|
insert(example_text)
|
||||||
|
|
||||||
local url = 'https://example.com'
|
local url1 = 'https://example.com'
|
||||||
|
local url2 = 'http://127.0.0.1'
|
||||||
|
|
||||||
screen:add_extra_attr_ids {
|
screen:add_extra_attr_ids {
|
||||||
u = { url = "https://example.com" },
|
u = { url = url1 },
|
||||||
|
uh = { url = url2, background = Screen.colors.Yellow },
|
||||||
}
|
}
|
||||||
|
|
||||||
api.nvim_buf_set_extmark(0, ns, 1, 4, {
|
api.nvim_buf_set_extmark(0, ns, 1, 4, {
|
||||||
end_col = 14,
|
end_col = 14,
|
||||||
url = url,
|
url = url1,
|
||||||
|
})
|
||||||
|
api.nvim_buf_set_extmark(0, ns, 2, 4, {
|
||||||
|
end_col = 17,
|
||||||
|
hl_group = 'Search',
|
||||||
|
url = url2,
|
||||||
})
|
})
|
||||||
|
|
||||||
screen:expect{grid=[[
|
screen:expect([[
|
||||||
for _,item in ipairs(items) do |
|
for _,item in ipairs(items) do |
|
||||||
{u:local text}, hl_id_cell, count = unpack(item) |
|
{u:local text}, hl_id_cell, count = unpack(item) |
|
||||||
if hl_id_cell ~= nil then |
|
{uh:if hl_id_cell} ~= nil then |
|
||||||
hl_id = hl_id_cell |
|
hl_id = hl_id_cell |
|
||||||
end |
|
end |
|
||||||
for _ = 1, (count or 1) do |
|
for _ = 1, (count or 1) do |
|
||||||
@ -2368,7 +2375,7 @@ describe('extmark decorations', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
|
|
|
|
||||||
]]}
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can replace marks in place with different decorations #27211', function()
|
it('can replace marks in place with different decorations #27211', function()
|
||||||
|
Reference in New Issue
Block a user