From 333d0b39fd358a64edfcf11ea52306550e0ddf66 Mon Sep 17 00:00:00 2001 From: Thomas Lambert Date: Tue, 2 May 2023 12:19:12 +0200 Subject: [PATCH] fix: no empty file when image paste fail (closes #131) --- lua/telekasten.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 461797e..e421fd5 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -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",