feat: deprecate initial diff
This commit is contained in:
parent
d43d8e4258
commit
2f95423c27
2 changed files with 3 additions and 65 deletions
12
doc/cp.txt
12
doc/cp.txt
|
|
@ -55,9 +55,6 @@ Action Commands ~
|
||||||
:CP debug Compile with debug flags and run current problem.
|
:CP debug Compile with debug flags and run current problem.
|
||||||
Includes sanitizers and debug symbols.
|
Includes sanitizers and debug symbols.
|
||||||
|
|
||||||
:CP diff Enter diff mode to compare actual vs expected
|
|
||||||
output. Run again to exit diff mode.
|
|
||||||
|
|
||||||
Navigation Commands ~
|
Navigation Commands ~
|
||||||
|
|
||||||
:CP next Navigate to next problem in current contest.
|
:CP next Navigate to next problem in current contest.
|
||||||
|
|
@ -241,15 +238,12 @@ Example: Setting up and solving AtCoder contest ABC324
|
||||||
5. If needed, debug: >
|
5. If needed, debug: >
|
||||||
:CP debug
|
:CP debug
|
||||||
<
|
<
|
||||||
6. Compare output visually: >
|
6. Move to next problem: >
|
||||||
:CP diff
|
|
||||||
<
|
|
||||||
7. Move to next problem: >
|
|
||||||
:CP next
|
:CP next
|
||||||
< This automatically sets up problem B
|
< This automatically sets up problem B
|
||||||
|
|
||||||
8. Continue solving problems with :CP next/:CP prev navigation
|
7. Continue solving problems with :CP next/:CP prev navigation
|
||||||
9. Submit solutions on AtCoder website
|
8. Submit solutions on AtCoder website
|
||||||
|
|
||||||
Example: Quick setup for single Codeforces problem >
|
Example: Quick setup for single Codeforces problem >
|
||||||
:CP codeforces 1933 a " One command setup
|
:CP codeforces 1933 a " One command setup
|
||||||
|
|
|
||||||
|
|
@ -192,60 +192,6 @@ local function debug_problem()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function diff_problem()
|
|
||||||
if state.diff_mode then
|
|
||||||
vim.cmd.diffoff()
|
|
||||||
if state.saved_session then
|
|
||||||
vim.cmd(("source %s"):format(state.saved_session))
|
|
||||||
vim.fn.delete(state.saved_session)
|
|
||||||
state.saved_session = nil
|
|
||||||
end
|
|
||||||
if state.temp_output then
|
|
||||||
vim.fn.delete(state.temp_output)
|
|
||||||
state.temp_output = nil
|
|
||||||
end
|
|
||||||
state.diff_mode = false
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local problem_id = get_current_problem()
|
|
||||||
if not problem_id then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local ctx = problem.create_context(state.platform, state.contest_id, state.problem_id, config)
|
|
||||||
|
|
||||||
if vim.fn.filereadable(ctx.expected_file) == 0 then
|
|
||||||
logger.log("no expected output file found", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.filereadable(ctx.output_file) == 0 then
|
|
||||||
logger.log("no output file found. run the problem first", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local output_lines = vim.fn.readfile(ctx.output_file)
|
|
||||||
local actual_output = {}
|
|
||||||
for i = 1, #output_lines do
|
|
||||||
if output_lines[i]:match("^%[code%]:") then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
table.insert(actual_output, output_lines[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
state.temp_output = vim.fn.tempname()
|
|
||||||
vim.fn.writefile(actual_output, state.temp_output)
|
|
||||||
|
|
||||||
state.saved_session = vim.fn.tempname()
|
|
||||||
vim.cmd(("mksession! %s"):format(state.saved_session))
|
|
||||||
|
|
||||||
vim.cmd("silent only")
|
|
||||||
vim.cmd(("edit %s"):format(state.temp_output))
|
|
||||||
vim.cmd.diffthis()
|
|
||||||
vim.cmd(("vertical diffsplit %s"):format(ctx.expected_file))
|
|
||||||
state.diff_mode = true
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param delta number 1 for next, -1 for prev
|
---@param delta number 1 for next, -1 for prev
|
||||||
---@param language? string
|
---@param language? string
|
||||||
|
|
@ -381,8 +327,6 @@ function M.handle_command(opts)
|
||||||
run_problem()
|
run_problem()
|
||||||
elseif cmd.action == "debug" then
|
elseif cmd.action == "debug" then
|
||||||
debug_problem()
|
debug_problem()
|
||||||
elseif cmd.action == "diff" then
|
|
||||||
diff_problem()
|
|
||||||
elseif cmd.action == "next" then
|
elseif cmd.action == "next" then
|
||||||
navigate_problem(1, cmd.language)
|
navigate_problem(1, cmd.language)
|
||||||
elseif cmd.action == "prev" then
|
elseif cmd.action == "prev" then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue