From 77be1ac578de82dd182808596db7505c5881f18a Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 12 Apr 2026 15:26:45 -0600 Subject: [PATCH] fix: close orphan bars + force redraw on tabline-disappear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When bufferline removes the tabline row (buffer count drops back to 1 after stepping out of a secondary file), the recovery ran but the screen showed DUPLICATE status bar rows stacked on top of each other. Root cause: during the tabline-disappear → window-shift cascade, nvim occasionally leaves a stale bar window while our recover path creates a new one, and/or keeps stale pixels from the pre-shift layout. Two defenses added to recover_chrome(): 1. Walk all windows; close any with filetype=TurboDebugBar that we're NOT tracking in sbar_win/cbar_win. Any orphaned bar window from a partial layout transition gets nuked before we create new ones. 2. Call `redraw!` at the end of recovery to force a full screen refresh, clearing any leftover pixels from the previous layout. Co-Authored-By: Claude Opus 4.6 (1M context) --- lua/turbo-debug/mode.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/turbo-debug/mode.lua b/lua/turbo-debug/mode.lua index ffcc656..52a0925 100644 --- a/lua/turbo-debug/mode.lua +++ b/lua/turbo-debug/mode.lua @@ -1117,6 +1117,18 @@ function M.enter() local function recover_chrome() vim.schedule(function() if not active then return end + -- Close any orphaned TurboDebugBar windows we're not tracking. + -- When the tabline toggles, nvim can sometimes leave a stale bar + -- window while creating a new one — which produces the "duplicate + -- turbo-debug rows stacked on top of each other" artifact. + for _, w in ipairs(vim.api.nvim_list_wins()) do + if vim.api.nvim_win_is_valid(w) and w ~= sbar_win and w ~= cbar_win then + local b = vim.api.nvim_win_get_buf(w) + if vim.api.nvim_buf_is_valid(b) and vim.bo[b].filetype == "TurboDebugBar" then + pcall(vim.api.nvim_win_close, w, true) + end + end + end if not (sbar_win and vim.api.nvim_win_is_valid(sbar_win)) then sbar_win, sbar_buf = nil, nil end @@ -1125,6 +1137,9 @@ function M.enter() end open_bars() -- idempotent render_bars() + -- Force a full redraw so any leftover pixels from the previous + -- layout (before tabline disappeared) don't linger on screen. + pcall(vim.cmd, "redraw!") end) end vim.api.nvim_create_autocmd("VimResized", { group = group, callback = recover_chrome })