Skip to content

Commit b96d64a

Browse files
authored
fix(render/default): remove unnecessary spaces when the icon is empty (#301)
1 parent c974bfb commit b96d64a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lua/notify/render/default.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local api = vim.api
22
local base = require("notify.render.base")
33

44
return function(bufnr, notif, highlights, config)
5-
local left_icon = notif.icon .. " "
5+
local left_icon = notif.icon == "" and "" or notif.icon .. " "
66
local max_message_width = math.max(math.max(unpack(vim.tbl_map(function(line)
77
return vim.fn.strchars(line)
88
end, notif.message))))
@@ -16,12 +16,11 @@ return function(bufnr, notif, highlights, config)
1616

1717
local namespace = base.namespace()
1818
api.nvim_buf_set_lines(bufnr, 0, 1, false, { "", "" })
19+
20+
local virt_text = left_icon == "" and {} or { { " " }, { left_icon, highlights.icon } }
21+
table.insert(virt_text, { left_title .. left_buffer, highlights.title })
1922
api.nvim_buf_set_extmark(bufnr, namespace, 0, 0, {
20-
virt_text = {
21-
{ " " },
22-
{ left_icon, highlights.icon },
23-
{ left_title .. left_buffer, highlights.title },
24-
},
23+
virt_text = virt_text,
2524
virt_text_win_col = 0,
2625
priority = 10,
2726
})

0 commit comments

Comments
 (0)