From 48acbc4d645fe99532b33051006a65a57d36b981 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Sun, 29 Dec 2024 16:00:47 +0900 Subject: fix(treesitter.foldexpr): refresh in the buffers affected by OptionSet --- runtime/lua/vim/treesitter/_fold.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/treesitter/_fold.lua b/runtime/lua/vim/treesitter/_fold.lua index 0cb5b497c7..10ba074ab5 100644 --- a/runtime/lua/vim/treesitter/_fold.lua +++ b/runtime/lua/vim/treesitter/_fold.lua @@ -378,9 +378,13 @@ api.nvim_create_autocmd('OptionSet', { pattern = { 'foldminlines', 'foldnestmax' }, desc = 'Refresh treesitter folds', callback = function() - for bufnr, _ in pairs(foldinfos) do + local bufs = vim.v.option_type == 'local' and { api.nvim_get_current_buf() } + or vim.tbl_keys(foldinfos) + for _, bufnr in ipairs(bufs) do foldinfos[bufnr] = FoldInfo.new() - compute_folds_levels(bufnr, foldinfos[bufnr]) + api.nvim_buf_call(bufnr, function() + compute_folds_levels(bufnr, foldinfos[bufnr]) + end) foldinfos[bufnr]:foldupdate(bufnr, 0, api.nvim_buf_line_count(bufnr)) end end, -- cgit