Skip to content

Commit 2c6dd75

Browse files
committed
fix(#3015): right-aligned icons are taken into account in grow
1 parent db8d7ac commit 2c6dd75

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/nvim-tree/view.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,19 @@ local function grow()
321321
max_width = get_width(M.View.max_width) - padding
322322
end
323323

324-
for _, l in pairs(lines) do
324+
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeExtmarks"]
325+
for line_nr, l in pairs(lines) do
325326
local count = vim.fn.strchars(l)
327+
-- also add space for right-aligned icons
328+
local extmarks = vim.api.nvim_buf_get_extmarks(0, ns_id, { line_nr, 0 }, { line_nr, -1 }, { details = true })
329+
for _, extmark in ipairs(extmarks) do
330+
local virt_texts = extmark[4].virt_text
331+
if virt_texts then
332+
for _, virt_text in ipairs(virt_texts) do
333+
count = count + vim.fn.strchars(virt_text[1])
334+
end
335+
end
336+
end
326337
if resizing_width < count then
327338
resizing_width = count
328339
end

0 commit comments

Comments
 (0)