fix: enable :CP next/prev
This commit is contained in:
parent
018f61af92
commit
2ac0a4996d
3 changed files with 22 additions and 8 deletions
|
|
@ -67,7 +67,7 @@ function M.setup_contest(platform, contest_id, language, problem_id)
|
|||
end, problems)
|
||||
|
||||
if cached_len ~= #problems then
|
||||
logger.log(('Found %s problems, expected %s; re-fetching'):format(cached_len, #problems))
|
||||
logger.log(('Fetching test cases...'):format(cached_len, #problems))
|
||||
scraper.scrape_all_tests(platform, contest_id, function(ev)
|
||||
local cached_tests = {}
|
||||
for i, t in ipairs(ev.tests) do
|
||||
|
|
@ -81,6 +81,7 @@ function M.setup_contest(platform, contest_id, language, problem_id)
|
|||
ev.timeout_ms or 0,
|
||||
ev.memory_mb or 0
|
||||
)
|
||||
logger.log('Test cases loaded.')
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
@ -203,6 +204,7 @@ function M.navigate_problem(direction, language)
|
|||
return
|
||||
end
|
||||
|
||||
require('cp.ui.panel').disable()
|
||||
M.setup_contest(platform, contest_id, language, problems[new_index].id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -114,4 +114,6 @@ function M.set_active_panel(panel)
|
|||
state.active_panel = panel
|
||||
end
|
||||
|
||||
M._state = state
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -9,6 +9,22 @@ local utils = require('cp.utils')
|
|||
local current_diff_layout = nil
|
||||
local current_mode = nil
|
||||
|
||||
function M.disable()
|
||||
local active_panel = state.get_active_panel()
|
||||
if not active_panel then
|
||||
logger.log('No active panel to close')
|
||||
return
|
||||
end
|
||||
|
||||
if active_panel == 'run' then
|
||||
M.toggle_run_panel()
|
||||
elseif active_panel == 'interactive' then
|
||||
M.toggle_interactive()
|
||||
else
|
||||
logger.log(('Unknown panel type: %s'):format(tostring(active_panel)))
|
||||
end
|
||||
end
|
||||
|
||||
function M.toggle_interactive()
|
||||
if state.get_active_panel() == 'interactive' then
|
||||
if state.interactive_buf and vim.api.nvim_buf_is_valid(state.interactive_buf) then
|
||||
|
|
@ -102,7 +118,6 @@ function M.toggle_interactive()
|
|||
state.interactive_buf = term_buf
|
||||
state.interactive_win = term_win
|
||||
state.set_active_panel('interactive')
|
||||
logger.log(('interactive opened, running %s'):format(binary))
|
||||
end
|
||||
|
||||
function M.toggle_run_panel(is_debug)
|
||||
|
|
@ -118,7 +133,6 @@ function M.toggle_run_panel(is_debug)
|
|||
state.saved_session = nil
|
||||
end
|
||||
state.set_active_panel(nil)
|
||||
logger.log('test panel closed')
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -301,11 +315,7 @@ function M.toggle_run_panel(is_debug)
|
|||
state.test_buffers = test_buffers
|
||||
state.test_windows = test_windows
|
||||
state.set_active_panel('run')
|
||||
local test_state = run.get_run_panel_state()
|
||||
logger.log(
|
||||
string.format('test panel opened (%d test cases)', #test_state.test_cases),
|
||||
vim.log.levels.INFO
|
||||
)
|
||||
logger.log('test panel opened')
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue