feat: file conflict prompt, empty submit guard, and lint fixes (#366)
## Problem
Loading a problem whose source file already exists silently overwrites
user code. Submitting an empty file sends a blank submission to the
platform. Two ruff lint violations existed in the scrapers.
## Solution
- `setup.lua`: when the target source file exists on the filesystem
(`vim.uv.fs_stat`), show an inline `Overwrite? [y/N]:` prompt. Declining
keeps the existing file open and registers state normally. Skipped when
the file is already loaded in a buffer.
- `submit.lua`: resolve path to absolute, use `vim.uv.fs_stat` to verify
existence, abort with WARN if `stat.size == 0` ("Submit aborted: source
file has no content").
- `scrapers/atcoder.py`: remove unused `pathlib.Path` import (F401).
- `scrapers/base.py`: move local imports to top of file (E402).
Closes #364, #365.
This commit is contained in:
parent
b7ddf4c253
commit
573b335646
9 changed files with 145 additions and 560 deletions
|
|
@ -53,11 +53,20 @@ function M.submit(opts)
|
|||
end
|
||||
|
||||
local source_file = state.get_source_file()
|
||||
if not source_file or vim.fn.filereadable(source_file) ~= 1 then
|
||||
if not source_file then
|
||||
logger.log('Source file not found', { level = vim.log.levels.ERROR })
|
||||
return
|
||||
end
|
||||
source_file = vim.fn.fnamemodify(source_file, ':p')
|
||||
local _stat = vim.uv.fs_stat(source_file)
|
||||
if not _stat then
|
||||
logger.log('Source file not found', { level = vim.log.levels.ERROR })
|
||||
return
|
||||
end
|
||||
if _stat.size == 0 then
|
||||
logger.log('Submit aborted: source file has no content', { level = vim.log.levels.WARN })
|
||||
return
|
||||
end
|
||||
|
||||
local submit_language = language
|
||||
local cfg = config.get_config()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue