refactor(submit): pass file path instead of source via stdin
Problem: Submit read the source file in Lua, piped the full content as stdin through to Python, then re-encoded it into an in-memory buffer just to hand it back to the browser's file input. Unnecessary roundtrip for AtCoder; CF also gains nothing from Lua owning the read. Solution: Pass `source_file` path as a CLI arg to the scraper instead of reading it in Lua and streaming via stdin. AtCoder calls `page.set_input_files(file_path)` directly. Codeforces reads the file with `Path(file_path).read_text()` before the browser session. Also saves the buffer with `vim.cmd.update()` before submitting.
This commit is contained in:
parent
b5a8fce13c
commit
c963728fe9
5 changed files with 22 additions and 38 deletions
|
|
@ -53,9 +53,7 @@ function M.submit(opts)
|
|||
end
|
||||
|
||||
prompt_credentials(platform, function(creds)
|
||||
local source_lines = vim.fn.readfile(source_file)
|
||||
local source_code = table.concat(source_lines, '\n')
|
||||
|
||||
vim.cmd.update()
|
||||
vim.notify('[cp.nvim] Submitting...', vim.log.levels.INFO)
|
||||
|
||||
require('cp.scraper').submit(
|
||||
|
|
@ -63,7 +61,7 @@ function M.submit(opts)
|
|||
contest_id,
|
||||
problem_id,
|
||||
language,
|
||||
source_code,
|
||||
source_file,
|
||||
creds,
|
||||
function(ev)
|
||||
vim.schedule(function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue