From f6b27b908904eee62fcb30998f601f2f01ed34d7 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 00:23:52 -0500 Subject: [PATCH] refactor(run): remove I/O view test navigation keymaps Problem: / in the I/O view buffers required the cursor to leave the source file to work, re-ran the solution on each press, and gave no indication of which test was active. The workflow is better served by :CP run for a specific test or :CP panel for full inspection. Solution: remove navigate_test, next_test_key/prev_test_key config options, and the associated current_test_index state field. --- lua/cp/config.lua | 18 ------------------ lua/cp/state.lua | 1 - lua/cp/ui/views.lua | 44 -------------------------------------------- 3 files changed, 63 deletions(-) diff --git a/lua/cp/config.lua b/lua/cp/config.lua index fcebc0e..ec6d75b 100644 --- a/lua/cp/config.lua +++ b/lua/cp/config.lua @@ -78,8 +78,6 @@ ---@class RunConfig ---@field width number ----@field next_test_key string|nil ----@field prev_test_key string|nil ---@field format_verdict VerdictFormatter ---@class EditConfig @@ -196,8 +194,6 @@ M.defaults = { ansi = true, run = { width = 0.3, - next_test_key = '', - prev_test_key = '', format_verdict = helpers.default_verdict_formatter, }, edit = { @@ -448,20 +444,6 @@ function M.setup(user_config) end, 'decimal between 0 and 1', }, - next_test_key = { - cfg.ui.run.next_test_key, - function(v) - return v == nil or (type(v) == 'string' and #v > 0) - end, - 'nil or non-empty string', - }, - prev_test_key = { - cfg.ui.run.prev_test_key, - function(v) - return v == nil or (type(v) == 'string' and #v > 0) - end, - 'nil or non-empty string', - }, format_verdict = { cfg.ui.run.format_verdict, 'function', diff --git a/lua/cp/state.lua b/lua/cp/state.lua index 6d99cbf..f0f4850 100644 --- a/lua/cp/state.lua +++ b/lua/cp/state.lua @@ -9,7 +9,6 @@ ---@class cp.IoViewState ---@field output_buf integer ---@field input_buf integer ----@field current_test_index integer? ---@field source_buf integer? ---@class cp.State diff --git a/lua/cp/ui/views.lua b/lua/cp/ui/views.lua index 041200e..0849164 100644 --- a/lua/cp/ui/views.lua +++ b/lua/cp/ui/views.lua @@ -240,7 +240,6 @@ local function get_or_create_io_buffers() state.set_io_view_state({ output_buf = output_buf, input_buf = input_buf, - current_test_index = 1, source_buf = current_source_buf, }) @@ -305,49 +304,6 @@ local function get_or_create_io_buffers() end, }) - local cfg = config_module.get_config() - local platform = state.get_platform() - local contest_id = state.get_contest_id() - local problem_id = state.get_problem_id() - - local function navigate_test(delta) - local io_view_state = state.get_io_view_state() - if not io_view_state then - return - end - if not platform or not contest_id or not problem_id then - return - end - local test_cases = cache.get_test_cases(platform, contest_id, problem_id) - if not test_cases or #test_cases == 0 then - return - end - local new_index = (io_view_state.current_test_index or 1) + delta - if new_index < 1 or new_index > #test_cases then - return - end - io_view_state.current_test_index = new_index - M.run_io_view(new_index) - end - - if cfg.ui.run.next_test_key then - vim.keymap.set('n', cfg.ui.run.next_test_key, function() - navigate_test(1) - end, { buffer = output_buf, silent = true, desc = 'Next test' }) - vim.keymap.set('n', cfg.ui.run.next_test_key, function() - navigate_test(1) - end, { buffer = input_buf, silent = true, desc = 'Next test' }) - end - - if cfg.ui.run.prev_test_key then - vim.keymap.set('n', cfg.ui.run.prev_test_key, function() - navigate_test(-1) - end, { buffer = output_buf, silent = true, desc = 'Previous test' }) - vim.keymap.set('n', cfg.ui.run.prev_test_key, function() - navigate_test(-1) - end, { buffer = input_buf, silent = true, desc = 'Previous test' }) - end - return output_buf, input_buf end