fix(ui): don' render extmarks for empty lines

This commit is contained in:
Folke Lemaitre 2023-05-05 14:06:59 +02:00
parent ceb413678d
commit dbe0e29d85
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 21 additions and 19 deletions

View File

@ -82,13 +82,14 @@ function Text:render(buf)
vim.api.nvim_buf_clear_namespace(buf, Config.ns, 0, -1) vim.api.nvim_buf_clear_namespace(buf, Config.ns, 0, -1)
for l, line in ipairs(self._lines) do for l, line in ipairs(self._lines) do
if lines[l] ~= "" then
local col = self.padding local col = self.padding
for _, segment in ipairs(line) do for _, segment in ipairs(line) do
local width = vim.fn.strlen(segment.str) local width = vim.fn.strlen(segment.str)
local extmark = segment.hl local extmark = segment.hl
if extmark and width > 0 then if extmark then
if type(extmark) == "string" then if type(extmark) == "string" then
extmark = { hl_group = extmark, end_col = col + width } extmark = { hl_group = extmark, end_col = col + width }
end end
@ -108,6 +109,7 @@ function Text:render(buf)
col = col + width col = col + width
end end
end end
end
end end
---@param patterns table<string,string> ---@param patterns table<string,string>