From f2f014e3797576eccc2320b711a336ea95f448fd Mon Sep 17 00:00:00 2001 From: Shadman Date: Sun, 2 May 2021 10:36:51 +0600 Subject: [PATCH] Fix: Transitional highlight not found error (#203) Changes: - transitional_highlight isn't created when both retrieval of fg or bg has failed - Transitional highlight is not looked for when section separators are disabled - empty section no longer returns highlight group as section data --- lua/lualine/highlight.lua | 3 +-- lua/lualine/init.lua | 4 ++-- lua/lualine/utils/section.lua | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 1145ae9..a668602 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -203,11 +203,10 @@ function M.get_transitional_highlights(left_section_data, right_section_data, -- using string.format to convert decimal to hexadecimal local fg = utils.extract_highlight_colors(left_highlight_name, 'bg') local bg = utils.extract_highlight_colors(right_highlight_name, 'bg') - if not fg then fg = 'none' end - if not bg then bg = 'none' end -- swap the bg and fg when reverse is true. As in that case highlight will -- be placed before section if reverse then fg, bg = bg, fg end + if not fg or not bg then return '' end -- Color retrieval failed M.highlight(highlight_name, fg, bg) end return '%#' .. highlight_name .. '#' diff --git a/lua/lualine/init.lua b/lua/lualine/init.lua index 8608664..aeca8b8 100644 --- a/lua/lualine/init.lua +++ b/lua/lualine/init.lua @@ -152,7 +152,7 @@ local function statusline(sections, is_focused) local current_section = status_builder[i] local next_section = status_builder[i + 1] or {} -- For 2nd half we need to show separator before section - if current_section.name > 'x' then + if current_section.name > 'x' and config.options.section_separators[2] ~= '' then local transitional_highlight = highlight.get_transitional_highlights( previous_section.data, current_section.data, true) @@ -167,7 +167,7 @@ local function statusline(sections, is_focused) table.insert(status, status_builder[i].data) -- For 1st half we need to show separator after section - if current_section.name < 'c' then + if current_section.name < 'c' and config.options.section_separators[1] ~= '' then local transitional_highlight = highlight.get_transitional_highlights( current_section.data, next_section.data) diff --git a/lua/lualine/utils/section.lua b/lua/lualine/utils/section.lua index 4fa3559..b35e209 100644 --- a/lua/lualine/utils/section.lua +++ b/lua/lualine/utils/section.lua @@ -39,7 +39,7 @@ function M.draw_section(section, highlight_name) -- Remove empty strings from status status = utils.list_shrink(status) local status_str = table.concat(status) - if status_str:find('%%#.*#') == 1 then + if status_str:find('%%#.*#') == 1 or #status_str == 0 then -- Don't prepend with old highlight when the component changes it imidiately return status_str else