fix(#3015): dynamic width no longer truncates on right_align icons (#3022)

This commit is contained in:
Šimon Mandlík 2024-12-13 22:54:18 +01:00 committed by GitHub
parent c3d9b1779f
commit f7b76cd1a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -321,8 +321,19 @@ local function grow()
max_width = get_width(M.View.max_width) - padding max_width = get_width(M.View.max_width) - padding
end end
for _, l in pairs(lines) do local ns_id = vim.api.nvim_get_namespaces()["NvimTreeExtmarks"]
for line_nr, l in pairs(lines) do
local count = vim.fn.strchars(l) local count = vim.fn.strchars(l)
-- also add space for right-aligned icons
local extmarks = vim.api.nvim_buf_get_extmarks(M.get_bufnr(), ns_id, { line_nr, 0 }, { line_nr, -1 }, { details = true })
for _, extmark in ipairs(extmarks) do
local virt_texts = extmark[4].virt_text
if virt_texts then
for _, virt_text in ipairs(virt_texts) do
count = count + vim.fn.strchars(virt_text[1])
end
end
end
if resizing_width < count then if resizing_width < count then
resizing_width = count resizing_width = count
end end