From 2c2b8b0906a93c9a56fe9084a637b36df94d278a Mon Sep 17 00:00:00 2001 From: Shadman Date: Sun, 14 Mar 2021 19:38:19 +0600 Subject: [PATCH] Fix #125 (diff highlight affecting other component) (#128) --- lua/lualine/utils/component.lua | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lua/lualine/utils/component.lua b/lua/lualine/utils/component.lua index b940126..1100599 100644 --- a/lua/lualine/utils/component.lua +++ b/lua/lualine/utils/component.lua @@ -37,11 +37,11 @@ local function apply_padding(status, options) end -- Applies custom highlights for component -local function apply_highlights(status, options) +local function apply_highlights(status, options, default_hl) if options.color_highlight then status = highlight.component_format_highlight(options.color_highlight) .. status end - return status + return status .. default_hl end -- Apply icon in front of component @@ -54,24 +54,16 @@ end -- Apply separator at end of component only when -- custom highlights haven't affected background -local function apply_spearator(status, options, highlight_name) +local function apply_spearator(status, options) local separator if options.separator and #options.separator > 0 then separator = options.separator elseif options.component_separators then if options.self.section < 'lualine_x' then separator = options.component_separators[1] else separator = options.component_separators[2] end - if not separator then - options.separator_applied = nil - return status - end options.separator = separator - else - options.separator_applied = nil - return status end - separator = highlight_name .. separator - status = status .. separator + if separator then status = status .. separator end options.separator_applied = separator return status end @@ -97,8 +89,8 @@ function M.draw_section(section, highlight_name) localstatus = apply_icon(localstatus, component) localstatus = apply_case(localstatus, component) localstatus = apply_padding(localstatus, component) - localstatus = apply_highlights(localstatus, component) - localstatus = apply_spearator(localstatus, component, highlight_name) + localstatus = apply_highlights(localstatus, component, highlight_name) + localstatus = apply_spearator(localstatus, component) if custom_highlight_at_begining or (#drawn_components > 0 and not drawn_components[#drawn_components].separator_applied)then -- Don't prepend with old highlight when the component changes it imidiately