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:
Barrett Ruth 2026-03-05 14:34:14 -05:00 committed by GitHub
parent 127089c57f
commit a202725cc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 269 additions and 168 deletions

View file

@ -43,7 +43,6 @@ end, {
vim.list_extend(candidates, platforms)
table.insert(candidates, 'cache')
table.insert(candidates, 'pick')
if platform and contest_id then
vim.list_extend(candidates, actions)
local cache = require('cp.cache')
@ -60,10 +59,11 @@ end, {
return filter_candidates(candidates)
elseif num_args == 3 then
if vim.tbl_contains(platforms, args[2]) then
local candidates = { 'login', 'logout' }
local cache = require('cp.cache')
cache.load()
local contests = cache.get_cached_contest_ids(args[2])
return filter_candidates(contests)
vim.list_extend(candidates, cache.get_cached_contest_ids(args[2]))
return filter_candidates(candidates)
elseif args[2] == 'cache' then
return filter_candidates({ 'clear', 'read' })
elseif args[2] == 'stress' or args[2] == 'interact' then
@ -103,8 +103,6 @@ end, {
end
end
return filter_candidates(candidates)
elseif args[2] == 'login' or args[2] == 'logout' then
return filter_candidates(platforms)
elseif args[2] == 'race' then
local candidates = { 'stop' }
vim.list_extend(candidates, platforms)