Skip to content

Commit 29c88bb

Browse files
committed
feat: remove right aligned icons from full name float, show float over right aligned icons
1 parent e7a7ad7 commit 29c88bb

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

lua/nvim-tree/renderer/components/full-name.lua

+7-21
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ local function show(opts)
5151
end
5252

5353
local text_width = vim.fn.strdisplaywidth(vim.fn.substitute(line, "[^[:print:]]*$", "", "g"))
54+
local win_width = effective_win_width()
5455

55-
-- also make space for right-aligned icons
56+
-- windows width reduced by right aligned icons
5657
local icon_ns_id = vim.api.nvim_get_namespaces()["NvimTreeExtmarks"]
5758
local icon_extmarks = vim.api.nvim_buf_get_extmarks(0, icon_ns_id, { line_nr - 1, 0 }, { line_nr - 1, -1 }, { details = true })
5859
text_width = text_width + view.extmarks_length(icon_extmarks)
5960

60-
local win_width = effective_win_width()
61-
6261
if text_width < win_width then
6362
return
6463
end
@@ -75,24 +74,11 @@ local function show(opts)
7574
})
7675
vim.wo[M.popup_win].winhl = view.View.winopts.winhl
7776

78-
local hl_ns_id = vim.api.nvim_get_namespaces()["NvimTreeHighlights"]
79-
local hl_extmarks = vim.api.nvim_buf_get_extmarks(0, hl_ns_id, { line_nr - 1, 0 }, { line_nr - 1, -1 }, { details = true })
77+
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeHighlights"]
78+
local extmarks = vim.api.nvim_buf_get_extmarks(0, ns_id, { line_nr - 1, 0 }, { line_nr - 1, -1 }, { details = true })
8079
vim.api.nvim_win_call(M.popup_win, function()
8180
vim.api.nvim_buf_set_lines(0, 0, -1, true, { line })
82-
83-
-- copy also right-aligned icons
84-
for _, extmark in ipairs(icon_extmarks) do
85-
local details = extmark[4]
86-
if details then
87-
vim.api.nvim_buf_set_extmark(0, icon_ns_id, 0, 0, {
88-
virt_text = details.virt_text,
89-
virt_text_pos = details.virt_text_pos,
90-
hl_mode = details.hl_mode,
91-
})
92-
end
93-
end
94-
95-
for _, extmark in ipairs(hl_extmarks) do
81+
for _, extmark in ipairs(extmarks) do
9682
-- nvim 0.10 luadoc is incorrect: vim.api.keyset.get_extmark_item is missing the extmark_id at the start
9783

9884
---@cast extmark table
@@ -103,9 +89,9 @@ local function show(opts)
10389

10490
if type(details) == "table" then
10591
if vim.fn.has("nvim-0.11") == 1 and vim.hl and vim.hl.range then
106-
vim.hl.range(0, hl_ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
92+
vim.hl.range(0, ns_id, details.hl_group, { 0, col }, { 0, details.end_col, }, {})
10793
else
108-
vim.api.nvim_buf_add_highlight(0, hl_ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
94+
vim.api.nvim_buf_add_highlight(0, ns_id, details.hl_group, 0, col, details.end_col) ---@diagnostic disable-line: deprecated
10995
end
11096
end
11197
end

0 commit comments

Comments
 (0)