fix(setup): set language state before setup_code hook on first open
Problem: when opening a contest for the first time (metadata not cached), the setup_code hook fired before state.set_language() was called, causing state.get_language() to return nil inside the hook. Solution: call state.set_language(lang) before the hook in the provisional-buffer branch of setup_contest(). The value is already computed at that point and is identical to what setup_problem() sets later, so the early write is idempotent.
This commit is contained in:
parent
19e71ac7fa
commit
d23b4e59d1
1 changed files with 2 additions and 0 deletions
|
|
@ -160,6 +160,8 @@ function M.setup_contest(platform, contest_id, problem_id, language)
|
|||
vim.bo[bufnr].buftype = ''
|
||||
vim.bo[bufnr].swapfile = false
|
||||
|
||||
state.set_language(lang)
|
||||
|
||||
if cfg.hooks and cfg.hooks.setup_code and not vim.b[bufnr].cp_setup_done then
|
||||
local ok = pcall(cfg.hooks.setup_code, state)
|
||||
if ok then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue