feat: streaming updates content (#170)

This commit is contained in:
yetone 2024-08-23 17:58:46 +08:00 committed by GitHub
parent 2fc266edd2
commit d7af33887d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1203,26 +1203,18 @@ Available commands:
---@type AvanteCompleteParser ---@type AvanteCompleteParser
local on_complete = function(err) local on_complete = function(err)
if err ~= nil then if err ~= nil then
self:update_content( self:update_content("\n\n🚨 Error: " .. vim.inspect(err), { stream = true, scroll = true })
content_prefix .. full_response .. "\n\n🚨 Error: " .. vim.inspect(err),
{ stream = false, scroll = true }
)
return return
end end
-- Execute when the stream request is actually completed -- Execute when the stream request is actually completed
self:update_content( self:update_content("\n\n🎉🎉🎉 **Generation complete!** Please review the code suggestions above.", {
content_prefix stream = true,
.. full_response
.. "\n\n🎉🎉🎉 **Generation complete!** Please review the code suggestions above.",
{
stream = false,
scroll = true, scroll = true,
callback = function() callback = function()
api.nvim_exec_autocmds("User", { pattern = VIEW_BUFFER_UPDATED_PATTERN }) api.nvim_exec_autocmds("User", { pattern = VIEW_BUFFER_UPDATED_PATTERN })
end, end,
} })
)
vim.defer_fn(function() vim.defer_fn(function()
self:create_input() -- Recreate input box self:create_input() -- Recreate input box