fix: systematic context guards and full panel lifecycle (#317)
## Problem The `CONTEST_ACTIONS` list in `handle_command` was a manually maintained parallel of `ACTIONS` that had already drifted (`pick` was incorrectly included, breaking `:CP pick` cold). `navigate_problem` only cancelled the `'run'` panel on `next`/`prev`, leaving interactive and stress terminals alive and in-flight `run_io_view` callbacks unguarded. `pick` and `cache` also appeared twice in tab-completion when a contest was active. ## Solution Replace `CONTEST_ACTIONS` with a `requires_context` field on `ParsedCommand`, set at each parse-site in `parse_command` so the semantics live with the action definition. Expand `navigate_problem` to call `cancel_io_view()` and dispatch `cancel_interactive`/`stress.cancel` for all panel types, mirroring the contest-switch logic. Filter already-present `pick` and `cache` from the context-conditional completion candidates.
This commit is contained in:
parent
7e7e135681
commit
6c036a7b2e
3 changed files with 40 additions and 11 deletions
|
|
@ -44,7 +44,12 @@ end, {
|
|||
table.insert(candidates, 'cache')
|
||||
table.insert(candidates, 'pick')
|
||||
if platform and contest_id then
|
||||
vim.list_extend(candidates, actions)
|
||||
vim.list_extend(
|
||||
candidates,
|
||||
vim.tbl_filter(function(a)
|
||||
return a ~= 'pick' and a ~= 'cache'
|
||||
end, actions)
|
||||
)
|
||||
local cache = require('cp.cache')
|
||||
cache.load()
|
||||
local contest_data = cache.get_contest_data(platform, contest_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue