Skip to content

Commit

Permalink
fix(ui): don' render extmarks for empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 5, 2023
1 parent ceb4136 commit dbe0e29
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions lua/lazy/view/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,32 @@ function Text:render(buf)
vim.api.nvim_buf_clear_namespace(buf, Config.ns, 0, -1)

for l, line in ipairs(self._lines) do
local col = self.padding

for _, segment in ipairs(line) do
local width = vim.fn.strlen(segment.str)

local extmark = segment.hl
if extmark and width > 0 then
if type(extmark) == "string" then
extmark = { hl_group = extmark, end_col = col + width }
if lines[l] ~= "" then
local col = self.padding

for _, segment in ipairs(line) do
local width = vim.fn.strlen(segment.str)

local extmark = segment.hl
if extmark then
if type(extmark) == "string" then
extmark = { hl_group = extmark, end_col = col + width }
end
---@cast extmark Extmark

local extmark_col = extmark.col or col
extmark.col = nil
local ok = pcall(vim.api.nvim_buf_set_extmark, buf, Config.ns, l - 1, extmark_col, extmark)
if not ok then
Util.error(
"Failed to set extmark. Please report a bug with this info:\n"
.. vim.inspect({ segment = segment, line = line })
)
end
end
---@cast extmark Extmark

local extmark_col = extmark.col or col
extmark.col = nil
local ok = pcall(vim.api.nvim_buf_set_extmark, buf, Config.ns, l - 1, extmark_col, extmark)
if not ok then
Util.error(
"Failed to set extmark. Please report a bug with this info:\n"
.. vim.inspect({ segment = segment, line = line })
)
end
end

col = col + width
col = col + width
end
end
end
end
Expand Down

0 comments on commit dbe0e29

Please sign in to comment.