fix: no empty file when image paste fail (closes #131)

This commit is contained in:
Thomas Lambert
2023-05-02 12:19:12 +02:00
parent 2efa3a51ff
commit 333d0b39fd

View File

@@ -403,7 +403,9 @@ local function imgFromClipboard()
local relpath = make_relative_path(vim.fn.expand("%:p"), png, "/")
local result = os.execute(get_paste_command(pngdir, pngname))
if not result then
if not result or result > 0 then
-- Remove empty file created by previous command if failed
os.execute("rm " .. pngdir .. "/" .. pngname)
vim.api.nvim_err_writeln(
string.format(
"Unable to write image %s. Is there an image on the clipboard? See also issue 131",