fix(open_url): open problem URL when switching problems
Also fix contest-change detection so URL open logic triggers when either platform or contest changes. This makes :CP next/:CP prev and problem jumps open the correct page when open_url is enabled. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
d3ac300ea0
commit
1c31abe3d6
2 changed files with 6 additions and 3 deletions
|
|
@ -143,7 +143,7 @@ run CSES problems with Rust using the single schema:
|
|||
(default: concatenates contest_id and problem_id, lowercased)
|
||||
{ui} (|CpUI|) UI settings: panel, diff backend, picker.
|
||||
{open_url} (boolean) Open the contest & problem url in the browser
|
||||
when the contest is first opened.
|
||||
when a new contest is opened or the active problem changes.
|
||||
|
||||
*CpPlatform*
|
||||
Fields: ~
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ end
|
|||
---@param language? string
|
||||
function M.setup_contest(platform, contest_id, problem_id, language)
|
||||
local old_platform, old_contest_id = state.get_platform(), state.get_contest_id()
|
||||
local old_problem_id = state.get_problem_id()
|
||||
|
||||
state.set_platform(platform)
|
||||
state.set_contest_id(contest_id)
|
||||
|
|
@ -133,7 +134,7 @@ function M.setup_contest(platform, contest_id, problem_id, language)
|
|||
end
|
||||
end
|
||||
|
||||
local is_new_contest = old_platform ~= platform and old_contest_id ~= contest_id
|
||||
local is_new_contest = old_platform ~= platform or old_contest_id ~= contest_id
|
||||
|
||||
cache.load()
|
||||
|
||||
|
|
@ -143,7 +144,9 @@ function M.setup_contest(platform, contest_id, problem_id, language)
|
|||
M.setup_problem(pid, language)
|
||||
start_tests(platform, contest_id, problems)
|
||||
|
||||
if config_module.get_config().open_url and is_new_contest and contest_data.url then
|
||||
local is_new_problem = old_problem_id ~= pid
|
||||
local should_open_url = config_module.get_config().open_url and (is_new_contest or is_new_problem)
|
||||
if should_open_url and contest_data.url then
|
||||
vim.ui.open(contest_data.url:format(pid))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue