Skip to content

Commit 72bea46

Browse files
committed
fix(math-renderer): use buffer local timers
1 parent 8d08289 commit 72bea46

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lua/neorg/modules/core/math/renderer/module.lua

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -328,43 +328,43 @@ module.public = {
328328
end,
329329
}
330330

331-
local running_proc = nil
332-
local render_timer = nil
331+
local running_proc = {}
332+
local render_timer = {}
333333
local function render_math()
334334
local buf = vim.api.nvim_get_current_buf()
335335
if not module.private.do_render then
336-
if render_timer then
337-
render_timer:stop()
338-
render_timer:close()
339-
render_timer = nil
336+
if render_timer[buf] then
337+
render_timer[buf]:stop()
338+
render_timer[buf]:close()
339+
render_timer[buf] = nil
340340
end
341341
return
342342
end
343343

344-
if not render_timer then
345-
render_timer = vim.uv.new_timer()
344+
if not render_timer[buf] then
345+
render_timer[buf] = vim.uv.new_timer()
346346
end
347347

348-
render_timer:start(module.config.public.debounce_ms, 0, function()
349-
render_timer:stop()
350-
render_timer:close()
351-
render_timer = nil
348+
render_timer[buf]:start(module.config.public.debounce_ms, 0, function()
349+
render_timer[buf]:stop()
350+
render_timer[buf]:close()
351+
render_timer[buf] = nil
352352

353-
if not running_proc then
354-
running_proc = nio.run(function()
353+
if not running_proc[buf] then
354+
running_proc[buf] = nio.run(function()
355355
nio.scheduler()
356356
module.public.async_math_renderer(buf)
357357
end, function()
358358
module.public.render_inline_math(module.private.math_images[buf] or {}, buf)
359-
running_proc = nil
359+
running_proc[buf] = nil
360360
end)
361361
end
362362
end)
363363
end
364364

365365
local function clear_at_cursor()
366366
local buf = vim.api.nvim_get_current_buf()
367-
if not module.private.do_render or render_timer then
367+
if not module.private.do_render or render_timer[buf] then
368368
return
369369
end
370370

0 commit comments

Comments
 (0)