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:
parent
924601ce99
commit
b3014e9c86
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