Remove hidden sections before reloading
This commit is contained in:
@@ -33,8 +33,9 @@ M.options = {
|
||||
function M.update_statusline()
|
||||
local cache = M.options.sections
|
||||
if common.is_active() then
|
||||
cache = statusline.remove_hidden_sections(cache)
|
||||
cache = statusline.reload_sections(cache)
|
||||
cache = statusline.filter_sections(cache)
|
||||
cache = statusline.remove_empty_sections(cache)
|
||||
cache = statusline.aggregate_sections(cache)
|
||||
api.nvim_win_set_var(g.statusline_winid, 'hardline_cache', cache)
|
||||
else
|
||||
|
||||
@@ -25,10 +25,10 @@ local function aggregate_sections(sections)
|
||||
return aggregated
|
||||
end
|
||||
|
||||
local function filter_sections(sections)
|
||||
local function remove_empty_sections(sections)
|
||||
local function filter(section)
|
||||
if type(section) == 'string' then return section ~= '' end
|
||||
return section.hide <= fn.winwidth(0) and section.item ~= ''
|
||||
if type(section) == 'table' then return section.item ~= '' end
|
||||
return section ~= ''
|
||||
end
|
||||
return vim.tbl_filter(filter, sections)
|
||||
end
|
||||
@@ -52,8 +52,16 @@ local function reload_sections(sections)
|
||||
return vim.tbl_map(map, sections)
|
||||
end
|
||||
|
||||
local function remove_hidden_sections(sections)
|
||||
local function filter(section)
|
||||
return not section.hide or section.hide <= fn.winwidth(0)
|
||||
end
|
||||
return vim.tbl_filter(filter, sections)
|
||||
end
|
||||
|
||||
return {
|
||||
aggregate_sections = aggregate_sections,
|
||||
filter_sections = filter_sections,
|
||||
remove_empty_sections = remove_empty_sections,
|
||||
reload_sections = reload_sections,
|
||||
remove_hidden_sections = remove_hidden_sections,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user