From 8a2ed691c0f5331627db00247c8fed7b94d5eca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=8D=E9=87=8E=E3=83=9A=E3=83=B3=E3=82=AE=E3=83=B3?= Date: Sun, 24 Aug 2025 16:21:55 +0800 Subject: [PATCH] fix: handle is already closing (#2613) Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- lua/avante/utils/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index 810f1aa..1e0e913 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -736,7 +736,11 @@ end ---@return string[] A new list of strings with line numbers prepended. function M.prepend_line_numbers(lines, start_line) start_line = start_line or 1 - return vim.iter(lines):map(function(line, i) return string.format("L%d: %s", i + start_line, line) end):totable() + return vim + .iter(lines) + :enumerate() + :map(function(i, line) return string.format("L%d: %s", i + start_line, line) end) + :totable() end ---Iterates through a list of strings and removes prefixes in form of "L: " from them @@ -756,7 +760,7 @@ function M.debounce(func, delay) return function(...) local args = { ... } - if timer then + if timer and not timer:is_closing() then timer:stop() timer:close() end