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 })