From 1d12cbb852b9b120ee148eafc533c7f53ba30336 Mon Sep 17 00:00:00 2001 From: Anton Rybianov Date: Sun, 17 Nov 2024 18:35:24 +0300 Subject: [PATCH] fix: defer execution to avoid segfaults --- lua/treesitter-context.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/treesitter-context.lua b/lua/treesitter-context.lua index 32e9d431..04bc91c6 100644 --- a/lua/treesitter-context.lua +++ b/lua/treesitter-context.lua @@ -29,7 +29,7 @@ local function throttle_by_id(f, ms) f(id) -- first call, execute immediately timers[id]:start(ms, 0, function() if waiting[id] then - vim.schedule(function() f(id) end) -- only execute if there are calls waiting + f(id) -- only execute if there are calls waiting end waiting[id] = nil timers[id] = nil @@ -173,7 +173,6 @@ function M.enable() if config.multiwindow then table.insert(update_events, 'WinResized') - table.insert(update_events, 'WinLeave') end autocmd(update_events, update) @@ -189,7 +188,7 @@ function M.enable() if config.multiwindow then autocmd({ 'WinClosed' }, close) else - autocmd({ 'BufLeave', 'WinLeave', 'WinClosed' }, close) + autocmd({ 'WinLeave', 'WinClosed' }, close) end autocmd('User', close, { pattern = 'SessionSavePre' })