fix: icons from different filetype component shareing same highlight group

fixes #610
This commit is contained in:
shadmansaleh 2022-03-18 07:52:18 +06:00
parent 399aaa564d
commit 7db1db3cd9
1 changed files with 3 additions and 3 deletions

View File

@ -15,6 +15,7 @@ local default_options = {
function M:init(options) function M:init(options)
M.super.init(self, options) M.super.init(self, options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
self.icon_hl_cache = {}
end end
function M.update_status() function M.update_status()
@ -22,7 +23,6 @@ function M.update_status()
return modules.utils.stl_escape(ft) return modules.utils.stl_escape(ft)
end end
local icon_hl_cache = {}
function M:apply_icon() function M:apply_icon()
if not self.options.icons_enabled then if not self.options.icons_enabled then
return return
@ -39,7 +39,7 @@ function M:apply_icon()
local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg') local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg')
if highlight_color then if highlight_color then
local default_highlight = self:get_default_hl() local default_highlight = self:get_default_hl()
local icon_highlight = icon_hl_cache[highlight_color] local icon_highlight = self.icon_hl_cache[highlight_color]
if not icon_highlight or not modules.highlight.highlight_exists(icon_highlight.name .. '_normal') then if not icon_highlight or not modules.highlight.highlight_exists(icon_highlight.name .. '_normal') then
icon_highlight = modules.highlight.create_component_highlight_group( icon_highlight = modules.highlight.create_component_highlight_group(
{ fg = highlight_color }, { fg = highlight_color },
@ -47,7 +47,7 @@ function M:apply_icon()
self.options, self.options,
false false
) )
icon_hl_cache[highlight_color] = icon_highlight self.icon_hl_cache[highlight_color] = icon_highlight
end end
icon = modules.highlight.component_format_highlight(icon_highlight) .. icon .. default_highlight icon = modules.highlight.component_format_highlight(icon_highlight) .. icon .. default_highlight