feat: add language to next/prev flags

This commit is contained in:
Barrett Ruth 2025-09-15 12:58:18 -04:00
parent 35008bea32
commit d0db42640d

View file

@ -266,7 +266,8 @@ local function diff_problem()
end end
---@param delta number 1 for next, -1 for prev ---@param delta number 1 for next, -1 for prev
local function navigate_problem(delta) ---@param language? string
local function navigate_problem(delta, language)
if not state.platform or not state.contest_id then if not state.platform or not state.contest_id then
logger.log("no contest set. run :CP <platform> <contest> first", vim.log.levels.ERROR) logger.log("no contest set. run :CP <platform> <contest> first", vim.log.levels.ERROR)
return return
@ -317,9 +318,9 @@ local function navigate_problem(delta)
local new_problem = problems[new_index] local new_problem = problems[new_index]
if state.platform == "cses" then if state.platform == "cses" then
setup_problem(new_problem.id) setup_problem(new_problem.id, nil, language)
else else
setup_problem(state.contest_id, new_problem.id) setup_problem(state.contest_id, new_problem.id, language)
end end
end end
@ -353,7 +354,7 @@ local function parse_command(args)
local first = filtered_args[1] local first = filtered_args[1]
if vim.tbl_contains(actions, first) then if vim.tbl_contains(actions, first) then
return { type = "action", action = first } return { type = "action", action = first, language = language }
end end
if vim.tbl_contains(platforms, first) then if vim.tbl_contains(platforms, first) then
@ -401,9 +402,9 @@ function M.handle_command(opts)
elseif cmd.action == "diff" then elseif cmd.action == "diff" then
diff_problem() diff_problem()
elseif cmd.action == "next" then elseif cmd.action == "next" then
navigate_problem(1) navigate_problem(1, cmd.language)
elseif cmd.action == "prev" then elseif cmd.action == "prev" then
navigate_problem(-1) navigate_problem(-1, cmd.language)
end end
return return
end end