fix(core): reset foldlevel on entering a diff window

This commit is contained in:
2026-05-19 20:26:58 +02:00
parent 3b8951758e
commit 73fa92afc8
+12
View File
@@ -66,6 +66,18 @@ vim.api.nvim_create_autocmd({ "BufReadPost" }, {
command = 'silent! normal! g`"zv', command = 'silent! normal! g`"zv',
}) })
vim.api.nvim_create_autocmd("BufWinEnter", {
desc = "Reset foldlevel to 0 when entering a diff window."
.. " Vim's partial diff-state restoration on buffer re-entry"
.. " (e.g. via <C-o>) doesn't re-apply foldlevel=0, so"
.. " foldlevelstart leaks through and folds appear open.",
callback = function()
if vim.wo.diff then
vim.wo.foldlevel = 0
end
end,
})
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { "c" }, pattern = { "c" },
callback = function() callback = function()