fix(setup): clear output buffer when switching contests
Problem: `setup_problem` only cleared the output buffer when `old_problem_id ~= problem_id`. If two different contests both had a problem with the same ID (e.g. `a`), the condition was false and stale output from the previous contest remained visible. Solution: clear the output buffer at the top of `proceed()` whenever `is_new_contest` is true, before any problem setup runs.
This commit is contained in:
parent
f9c7b83b0e
commit
a67e0d5db8
1 changed files with 6 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue