Skip to content

Commit a098f96

Browse files
fix: properly schedule vim.notify and nvim_echo calls
1 parent 19a6948 commit a098f96

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lua/claudecode/logger.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ local function log(level, component, message_parts)
6868
end
6969
end
7070

71-
if level == M.levels.ERROR then
72-
vim.notify(prefix .. " " .. message, vim.log.levels.ERROR, { title = "ClaudeCode Error" })
73-
elseif level == M.levels.WARN then
74-
vim.notify(prefix .. " " .. message, vim.log.levels.WARN, { title = "ClaudeCode Warning" })
75-
else
76-
-- For INFO, DEBUG, TRACE, use nvim_echo to avoid flooding notifications,
77-
-- to make them appear in :messages, and wrap in vim.schedule
78-
-- to avoid "nvim_echo must not be called in a fast event context".
79-
vim.schedule(function()
71+
-- Wrap all vim.notify and nvim_echo calls in vim.schedule to avoid
72+
-- "nvim_echo must not be called in a fast event context" errors
73+
vim.schedule(function()
74+
if level == M.levels.ERROR then
75+
vim.notify(prefix .. " " .. message, vim.log.levels.ERROR, { title = "ClaudeCode Error" })
76+
elseif level == M.levels.WARN then
77+
vim.notify(prefix .. " " .. message, vim.log.levels.WARN, { title = "ClaudeCode Warning" })
78+
else
79+
-- For INFO, DEBUG, TRACE, use nvim_echo to avoid flooding notifications
8080
vim.api.nvim_echo({ { prefix .. " " .. message, "Normal" } }, true, {})
81-
end)
82-
end
81+
end
82+
end)
8383
end
8484

8585
--- @param component string|nil Optional component/module name.

0 commit comments

Comments
 (0)