fix(setup): clear output buffer when switching contests (#313)

## Problem

`setup_problem` only cleared the output buffer when `old_problem_id ~=
problem_id`. If two different contests share a problem with the same ID
(e.g. both have `a`), the condition is false and stale output from the
previous contest remains visible.

## Solution

Clear the output buffer at the top of `proceed()` in `setup_contest`
whenever `is_new_contest` is true, before any problem setup runs.

Closes #303.
This commit is contained in:
Barrett Ruth 2026-03-05 15:31:47 -05:00 committed by GitHub
parent 924601ce99
commit b3014e9c86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,6 +182,12 @@ function M.setup_contest(platform, contest_id, problem_id, language)
cache.load()
local function proceed(contest_data)
if is_new_contest then
local io_state = state.get_io_view_state()
if io_state and io_state.output_buf and vim.api.nvim_buf_is_valid(io_state.output_buf) then
require('cp.utils').update_buffer_content(io_state.output_buf, {}, nil, nil)
end
end
local problems = contest_data.problems
local pid = problem_id and problem_id or problems[1].id
M.setup_problem(pid, language)