Merge pull request #157 from barrett-ruth/feat/buf-difficulties

fix: don't always open new window
This commit is contained in:
Barrett Ruth 2025-10-13 02:34:11 +02:00 committed by GitHub
commit 0c87ce2ac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -16,8 +16,6 @@ function M.restore_from_current_file()
end
local setup = require('cp.setup')
state.set_platform(file_state.platform)
state.set_contest_id(file_state.contest_id)
state.set_problem_id(file_state.problem_id)
setup.setup_contest(
file_state.platform,

View file

@ -68,8 +68,13 @@ end
---@param problem_id? string
---@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()
state.set_platform(platform)
state.set_contest_id(contest_id)
local is_new_contest = old_platform ~= platform and old_contest_id ~= contest_id
cache.load()
local function proceed(contest_data)
@ -78,7 +83,7 @@ function M.setup_contest(platform, contest_id, problem_id, language)
M.setup_problem(pid, language)
start_tests(platform, contest_id, problems)
if contest_data.url and config_module.get_config().open_url then
if config_module.get_config().open_url and is_new_contest and contest_data.url then
vim.ui.open(contest_data.url)
end
end