fix(race): improve cancellation log and prefix timer notifications

Problem: Race cancellation logged a generic message without identifying
which race was cancelled. Timer notifications used `[cp.nvim]` without
the colon prefix that `logger.log` uses.

Solution: Log cancelled race with platform display name and contest name.
Add colon to `[cp.nvim]:` prefix in timer countdown notifications.
This commit is contained in:
Barrett Ruth 2026-03-06 18:28:56 -05:00
parent bff6ce6454
commit f5ae20b971
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -126,7 +126,7 @@ function M.start(platform, contest_id, language)
require('cp.setup').setup_contest(p, c, nil, l)
else
vim.notify(
('[cp.nvim] %s starts in %s'):format(race_state.contest_name, format_countdown(r)),
('[cp.nvim]: %s starts in %s'):format(race_state.contest_name, format_countdown(r)),
vim.log.levels.INFO
)
end
@ -137,8 +137,11 @@ end
function M.stop()
local timer = race_state.timer
if not timer then
logger.log('No active race', { level = vim.log.levels.WARN })
return
end
local display = constants.PLATFORM_DISPLAY_NAMES[race_state.platform] or race_state.platform
local name = race_state.contest_name or race_state.contest_id
timer:stop()
timer:close()
race_state.timer = nil
@ -147,6 +150,7 @@ function M.stop()
race_state.contest_name = nil
race_state.language = nil
race_state.start_time = nil
logger.log(('Cancelled %s race "%s"'):format(display, name), { level = vim.log.levels.INFO, override = true })
end
function M.status()