From 80864a9d4988adcddbc64f60e1dc3e46e2fa6dde Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Tue, 16 Dec 2025 22:42:56 +0100 Subject: [PATCH] powerline for real --- lua/zterm-navigator/init.lua | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lua/zterm-navigator/init.lua b/lua/zterm-navigator/init.lua index f07dac9..e691fa5 100644 --- a/lua/zterm-navigator/init.lua +++ b/lua/zterm-navigator/init.lua @@ -278,6 +278,26 @@ local function update_statusline() end end +-- Debounce timer for statusline updates +local update_timer = nil + +-- Schedule a statusline update with debouncing +local function schedule_update() + -- Cancel any pending update + if update_timer then + update_timer:stop() + update_timer:close() + update_timer = nil + end + + -- Schedule a new update + update_timer = vim.loop.new_timer() + update_timer:start(5, 0, vim.schedule_wrap(function() + update_timer = nil + update_statusline() + end)) +end + -- Saved laststatus value to restore on disable M._saved_laststatus = nil @@ -313,8 +333,7 @@ function M.enable_statusline() vim.api.nvim_create_autocmd(events, { group = M._statusline_augroup, callback = function() - -- Defer slightly to batch rapid updates - vim.defer_fn(update_statusline, 10) + schedule_update() end, })