feat: format

This commit is contained in:
Barrett Ruth 2025-09-15 22:40:16 -04:00
parent d5b3c9a881
commit 0951944e8c
2 changed files with 18 additions and 7 deletions

View file

@ -248,7 +248,9 @@ local function toggle_test_panel()
logger.log(("navigating test by %d"):format(delta))
local test_state = test_module.get_test_panel_state()
local new_index = test_state.current_index + delta
logger.log(("current: %d, new: %d, total: %d"):format(test_state.current_index, new_index, #test_state.test_cases))
logger.log(
("current: %d, new: %d, total: %d"):format(test_state.current_index, new_index, #test_state.test_cases)
)
if new_index >= 1 and new_index <= #test_state.test_cases then
test_state.current_index = new_index
toggle_test_panel()

View file

@ -163,7 +163,7 @@ function M.scrape_problem(ctx)
table.insert(test_cases, {
index = i,
input = input_content,
output = expected_content
output = expected_content,
})
i = i + 1
else
@ -228,7 +228,6 @@ function M.scrape_problem(ctx)
timeout = 30000,
}):wait()
if result.code ~= 0 then
return {
success = false,
@ -246,7 +245,6 @@ function M.scrape_problem(ctx)
}
end
if not data.success then
return data
end
@ -269,8 +267,20 @@ function M.scrape_problem(ctx)
vim.fn.writefile(vim.split(expected_content, "\n", true), expected_file)
end
local combined_input = data.combined and data.combined.input:gsub("\r", "") or table.concat(vim.tbl_map(function(tc) return tc.input end, data.test_cases), "\n")
local combined_output = data.combined and data.combined.output:gsub("\r", "") or table.concat(vim.tbl_map(function(tc) return tc.output end, data.test_cases), "\n")
local combined_input = data.combined and data.combined.input:gsub("\r", "")
or table.concat(
vim.tbl_map(function(tc)
return tc.input
end, data.test_cases),
"\n"
)
local combined_output = data.combined and data.combined.output:gsub("\r", "")
or table.concat(
vim.tbl_map(function(tc)
return tc.output
end, data.test_cases),
"\n"
)
if ctx.contest == "atcoder" then
combined_input = tostring(#data.test_cases) .. "\n" .. combined_input
@ -280,7 +290,6 @@ function M.scrape_problem(ctx)
vim.fn.writefile(vim.split(combined_output, "\n", true), ctx.expected_file)
end
return {
success = true,
problem_id = ctx.problem_name,