diff --git a/lua/dapui/init.lua b/lua/dapui/init.lua index 06045e6..8a096a9 100644 --- a/lua/dapui/init.lua +++ b/lua/dapui/init.lua @@ -74,6 +74,8 @@ end ---@eval return require('dapui.config')._format_default() ---@param user_config? dapui.Config function dapui.setup(user_config) + util.stop_render_tasks() + config.setup(user_config) local client = require("dapui.client")(dap.session) diff --git a/lua/dapui/util.lua b/lua/dapui/util.lua index 9328935..6840e99 100644 --- a/lua/dapui/util.lua +++ b/lua/dapui/util.lua @@ -5,11 +5,20 @@ local M = {} local api = async.api +local render_tasks = {} + +function M.stop_render_tasks() + for _, task in ipairs(render_tasks) do + task.cancel() + end + render_tasks = {} +end + ---@return function function M.create_render_loop(render) local render_event = async.control.event() - async.run(function() + render_tasks[#render_tasks + 1] = async.run(function() while true do render_event.wait() render_event.clear()