fix(submit): use file path over stdin; fix CF CodeMirror textarea (#305)
## Problem After the initial submit hardening, two issues remained: source code was read in Lua and piped as stdin to the scraper (unnecessary roundtrip since the file exists on disk), and CF's `page.fill()` timed out on the hidden `textarea[name="source"]` because CodeMirror owns the editor state. ## Solution Pass the source file path as a CLI arg instead — AtCoder calls `page.set_input_files(file_path)` directly, CF reads it with `Path(file_path).read_text()`. Fix CF source injection via `page.evaluate()` into the CodeMirror instance. Extract `BROWSER_SUBMIT_NAV_TIMEOUT` as a per-platform `defaultdict` (CF defaults to 2× nav timeout). Save the buffer with `vim.cmd.update()` before submitting.
This commit is contained in:
parent
127089c57f
commit
a202725cc5
28 changed files with 269 additions and 168 deletions
|
|
@ -83,8 +83,6 @@ local function parse_command(args)
|
|||
else
|
||||
return { type = 'action', action = 'interact' }
|
||||
end
|
||||
elseif first == 'login' or first == 'logout' then
|
||||
return { type = 'action', action = first, platform = args[2] }
|
||||
elseif first == 'stress' then
|
||||
return {
|
||||
type = 'action',
|
||||
|
|
@ -245,6 +243,9 @@ local function parse_command(args)
|
|||
message = 'Too few arguments - specify a contest.',
|
||||
}
|
||||
elseif #args == 2 then
|
||||
if args[2] == 'login' or args[2] == 'logout' then
|
||||
return { type = 'action', action = args[2], platform = first }
|
||||
end
|
||||
return {
|
||||
type = 'contest_setup',
|
||||
platform = first,
|
||||
|
|
@ -287,7 +288,7 @@ function M.handle_command(opts)
|
|||
local cmd = parse_command(opts.fargs)
|
||||
|
||||
if cmd.type == 'error' then
|
||||
logger.log(cmd.message, vim.log.levels.ERROR)
|
||||
logger.log(cmd.message, { level = vim.log.levels.ERROR })
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -336,7 +337,7 @@ function M.handle_command(opts)
|
|||
local problem_id = cmd.problem_id
|
||||
|
||||
if not (platform and contest_id) then
|
||||
logger.log('No contest is currently active.', vim.log.levels.ERROR)
|
||||
logger.log('No contest is currently active.', { level = vim.log.levels.ERROR })
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -351,7 +352,7 @@ function M.handle_command(opts)
|
|||
contest_id,
|
||||
problem_id
|
||||
),
|
||||
vim.log.levels.ERROR
|
||||
{ level = vim.log.levels.ERROR }
|
||||
)
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue