Skip to content

Commit ecbe3ad

Browse files
authored
fix: folder icon highlight (#1086)
1 parent e307ad9 commit ecbe3ad

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lua/nvim-tree/renderer/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ local function get_trailing_length()
2424
return vim.g.nvim_tree_add_trailing and 1 or 0
2525
end
2626

27-
local set_folder_hl = function(line, depth, git_icon_len, _, hl_group)
27+
local set_folder_hl = function(line, depth, git_icon_len, _, hl_group, _)
2828
table.insert(hl, { hl_group, line, depth + git_icon_len, -1 })
2929
end
3030

@@ -52,10 +52,10 @@ if icon_state.show_folder_icon then
5252
end
5353
return n .. icon_padding
5454
end
55-
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
56-
table.insert(hl, { hl_group, line, depth + icon_len, depth + icon_len + name_len + get_trailing_length() })
57-
local hl_icon = (vim.g.nvim_tree_highlight_opened_files or 0) ~= 0 and hl_group or "NvimTreeFolderIcon"
55+
set_folder_hl = function(line, depth, icon_len, name_len, hl_icongroup, hl_fnamegroup)
56+
local hl_icon = should_hl_opened_files and hl_icongroup or "NvimTreeFolderIcon"
5857
table.insert(hl, { hl_icon, line, depth, depth + icon_len })
58+
table.insert(hl, { hl_fnamegroup, line, depth + icon_len, depth + icon_len + name_len + get_trailing_length() })
5959
end
6060
end
6161

@@ -156,9 +156,9 @@ local function update_draw_data(tree, depth, markers)
156156
if special[node.absolute_path] then
157157
folder_hl = "NvimTreeSpecialFolderName"
158158
end
159-
set_folder_hl(index, offset, #icon + #git_icon, #name, folder_hl)
159+
set_folder_hl(index, offset, #icon + #git_icon, #name, "NvimTreeFolderIcon", folder_hl)
160160
if git_hl then
161-
set_folder_hl(index, offset, #icon + #git_icon, #name, git_hl)
161+
set_folder_hl(index, offset, #icon + #git_icon, #name, git_hl, git_hl)
162162
end
163163
index = index + 1
164164
if node.open then

0 commit comments

Comments
 (0)