From 1e72ae9ae306bb59070786569a426ae522229f61 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 8 Sep 2021 20:53:23 +0600 Subject: [PATCH] fix: fix wrong trans sep when only section a and z are present --- lua/lualine.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lua/lualine.lua b/lua/lualine.lua index a99c192..85d3e48 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -55,6 +55,8 @@ end local function apply_transitional_separators(status) local status_applied = {} -- Collects all the pieces for concatation local last_hl -- Stores lash highligjt group that we found + local last_hl_reseted = false -- Whether last_hl is nil because we reseted + -- it after %= local copied_pos = 1 -- Tracks how much we've copied over to status_applied local str_checked = 1 -- Tracks where the searcher head is at @@ -77,9 +79,14 @@ local function apply_transitional_separators(status) -- %s{sep} is marker for left separator and local sep = status:match('^%%s{(.-)}', str_checked) str_checked = str_checked + #sep + 4 -- 4 = len(%{}) - local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, false) - if trans_sep then - table.insert(status_applied, trans_sep) + if not (last_hl == nil and last_hl_reseted) then + local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, false) + if trans_sep then + table.insert(status_applied, trans_sep) + end + end + if last_hl_reseted then + last_hl_reseted = false end copied_pos = str_checked elseif next_char == 'S' then @@ -105,6 +112,7 @@ local function apply_transitional_separators(status) -- we have another visual bug that occurs less frequently. -- Annoying Edge Cases............................................ last_hl = nil + last_hl_reseted = true str_checked = str_checked + 1 -- Skip the following % too else str_checked = str_checked + 1 -- Push it forward to avoid inf loop