From 00987bb0fffa07f39922803df7d0a2b0bd6ba4ba Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 6 Nov 2025 01:31:50 -0500 Subject: [PATCH] feat(io): cleanup view --- lua/cp/pickers/fzf_lua.lua | 2 -- lua/cp/runner/execute.lua | 18 ++++++++++++------ lua/cp/scraper.lua | 4 ++-- lua/cp/ui/views.lua | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lua/cp/pickers/fzf_lua.lua b/lua/cp/pickers/fzf_lua.lua index d1af5d2..e463d5a 100644 --- a/lua/cp/pickers/fzf_lua.lua +++ b/lua/cp/pickers/fzf_lua.lua @@ -51,8 +51,6 @@ local function contest_picker(platform, refresh, language) end end, ['ctrl-r'] = function() - local cache = require('cp.cache') - cache.clear_contest_list(platform) contest_picker(platform, true, language) end, }, diff --git a/lua/cp/runner/execute.lua b/lua/cp/runner/execute.lua index 8f004e5..c1c141e 100644 --- a/lua/cp/runner/execute.lua +++ b/lua/cp/runner/execute.lua @@ -73,13 +73,19 @@ local function parse_and_strip_time_v(output) return s, 0 end - local k = last_i - 1 - while k >= 1 do - local ch = s:sub(k, k) - if ch ~= ' ' and ch ~= '\t' then - break + local tab_before_marker = s:find('\t[^\t]*Command being timed:', 1) + local k + if tab_before_marker then + k = tab_before_marker - 1 + else + k = last_i - 1 + while k >= 1 do + local ch = s:sub(k, k) + if ch == '\n' then + break + end + k = k - 1 end - k = k - 1 end local head = s:sub(1, k) diff --git a/lua/cp/scraper.lua b/lua/cp/scraper.lua index a21aa7a..7fb1376 100644 --- a/lua/cp/scraper.lua +++ b/lua/cp/scraper.lua @@ -189,8 +189,8 @@ function M.scrape_all_tests(platform, contest_id, callback) local expected_file = 'io/' .. base_name .. '.' .. i .. '.cpout' local input_content = t.input:gsub('\r', '') local expected_content = t.expected:gsub('\r', '') - vim.fn.writefile(vim.split(input_content, '\n', { trimempty = true }), input_file) - vim.fn.writefile(vim.split(expected_content, '\n', { trimempty = true }), expected_file) + vim.fn.writefile(vim.split(input_content, '\n'), input_file) + vim.fn.writefile(vim.split(expected_content, '\n'), expected_file) end if type(callback) == 'function' then callback({ diff --git a/lua/cp/ui/views.lua b/lua/cp/ui/views.lua index d541dec..6c92b97 100644 --- a/lua/cp/ui/views.lua +++ b/lua/cp/ui/views.lua @@ -434,8 +434,8 @@ function M.run_io_view(test_indices_arg, debug, mode) end if mode == 'combined' then - local test_cases = cache.get_test_cases(platform, contest_id, problem_id) - if test_cases and #test_cases > 1 then + local problem_data = contest_data.problems[contest_data.index_map[problem_id]] + if not problem_data.multi_test then mode = 'individual' end end @@ -545,7 +545,7 @@ function M.run_io_view(test_indices_arg, debug, mode) input_lines = vim.split(combined.input, '\n') - if result.actual then + if result.actual and result.actual ~= '' then output_lines = vim.split(result.actual, '\n') end