Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lua/docscribe/core/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ function M.generate_docs(function_text, insertion_row, indentation_level)

notification_utils.start_spinner_notification()
llm_utils.generate_docs(function_text, function(docs, err)
is_generating = false
vim.schedule(function()
is_generating = false

if not docs then
vim.schedule(function()
if not docs then
notification_utils.replace_spinner_notification("Could not generate docs: " .. err, true)
highlight_utils.clear_highlight()
end)
return
end

vim.schedule(function()
return
end
handle_successful_doc_generation(docs, insertion_row, indentation_level)
end)
end)
Expand Down
18 changes: 10 additions & 8 deletions lua/docscribe/ui/notifications.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ local spinner_notification_id
--- Updates the spinner animation by cycling through the `spinner_chars`.
--- This function updates the spinner message in the notification.
local function update_spinner()
if not spinner_timer then
return
end

current_spinner_idx = (current_spinner_idx % #spinner_chars) + 1

spinner_notification_id =
Expand Down Expand Up @@ -62,14 +66,12 @@ function M.replace_spinner_notification(message, caught_an_error)

local log_level = caught_an_error and vim.log.levels.ERROR or vim.log.levels.INFO

if spinner_notification_id then
M.docscribe_notify(message, log_level, {
timeout = config.get_config("ui").highlight.timeout,
hide_from_history = false,
replace = spinner_notification_id,
})
spinner_notification_id = nil
end
M.docscribe_notify(message, log_level, {
timeout = config.get_config("ui").highlight.timeout,
hide_from_history = false,
replace = spinner_notification_id,
})
spinner_notification_id = nil
end

return M