fix: use vim.fn.system for image paste (#131, #241)

This commit is contained in:
Thomas Lambert
2023-05-02 13:02:34 +02:00
parent 333d0b39fd
commit 67c5758a13

View File

@@ -402,17 +402,16 @@ local function imgFromClipboard()
local png = pngdir .. "/" .. pngname
local relpath = make_relative_path(vim.fn.expand("%:p"), png, "/")
local result = os.execute(get_paste_command(pngdir, pngname))
if not result or result > 0 then
local output = vim.fn.system(get_paste_command(pngdir, pngname))
if output ~= "" then
-- Remove empty file created by previous command if failed
os.execute("rm " .. pngdir .. "/" .. pngname)
vim.fn.system("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",
"Unable to write image %s.\nIs there an image on the clipboard?\nSee also issue 131",
png
)
)
return
end
if fileutils.file_exists(png) then