fix(decor): don't use separate DecorSignHighlight for url (#30096)

This commit is contained in:
zeertzjq
2024-08-20 08:20:19 +08:00
committed by GitHub
parent 1d11808bfd
commit a8fbe1d409
3 changed files with 27 additions and 21 deletions

View File

@@ -1798,10 +1798,15 @@ describe('API/extmarks', function()
end)
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 })
eq(1, #extmarks)
eq('https://example.com', extmarks[1][4].url)
eq(2, #extmarks)
eq(url1, extmarks[1][4].url)
eq(url2, extmarks[2][4].url)
eq('Search', extmarks[2][4].hl_group)
end)
it('respects priority', function()

View File

@@ -2341,21 +2341,28 @@ describe('extmark decorations', function()
it('supports URLs', function()
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 {
u = { url = "https://example.com" },
u = { url = url1 },
uh = { url = url2, background = Screen.colors.Yellow },
}
api.nvim_buf_set_extmark(0, ns, 1, 4, {
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 |
{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 |
end |
for _ = 1, (count or 1) do |
@@ -2368,7 +2375,7 @@ describe('extmark decorations', function()
{1:~ }|
{1:~ }|
|
]]}
]])
end)
it('can replace marks in place with different decorations #27211', function()