From 907387b64fa9e670ff789f0fabf88973aa053fd0 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 13:31:10 -0500 Subject: [PATCH] fix(init): force redraw after deferred filetype retry Problem: when attach() runs from a FileType autocmd, did_filetype() = 1 causes vim.filetype.match to return nil for function-handled extensions (.lua, .py, .sh, etc). ensure_cache correctly schedules a deferred invalidate_cache via vim.schedule, but invalidate_cache only sets tick = -1 without forcing a redraw. Since the buffer is static, Neovim never triggers the decoration provider again, so the reparse with did_filetype() = 0 never happens until the user interacts. Solution: call vim.cmd('redraw') after invalidate_cache in the deferred callback. This forces the decoration provider to re-enter on_buf, which sees the invalidated tick, reparses with did_filetype() = 0, and applies language-specific treesitter highlighting. --- lua/diffs/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/diffs/init.lua b/lua/diffs/init.lua index 391f239..07e04d6 100644 --- a/lua/diffs/init.lua +++ b/lua/diffs/init.lua @@ -339,6 +339,7 @@ local function ensure_cache(bufnr) if vim.api.nvim_buf_is_valid(bufnr) and hunk_cache[bufnr] then dbg('retrying filetype detection for buffer %d (was blocked by did_filetype)', bufnr) invalidate_cache(bufnr) + vim.cmd('redraw') end end) end