feat: remember the last selected model (#2518)

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: yetone <yetoneful@gmail.com>
This commit is contained in:
NekoNekoNiko120
2025-07-28 13:21:49 +08:00
committed by GitHub
parent 7e50de8904
commit 5e4eb8652b
4 changed files with 72 additions and 8 deletions

View File

@@ -707,11 +707,19 @@ function M.curl(opts)
-- Mark as completed first to prevent error handler from running
completed = true
-- Attempt to shutdown the active job, but ignore any errors
xpcall(function() active_job:shutdown() end, function(err)
Utils.debug("Ignored error during job shutdown: " .. vim.inspect(err))
return err
end)
-- 检查 active_job 的状态
local job_is_alive = pcall(function() return active_job:is_closing() == false end)
-- 只有当 job 仍然活跃时才尝试关闭它
if job_is_alive then
-- Attempt to shutdown the active job, but ignore any errors
xpcall(function() active_job:shutdown() end, function(err)
Utils.debug("Ignored error during job shutdown: " .. vim.inspect(err))
return err
end)
else
Utils.debug("Job already closed, skipping shutdown")
end
Utils.debug("LLM request cancelled")
active_job = nil