From 67c5758a13352d6dcfdf9353283956c34ca06d3b Mon Sep 17 00:00:00 2001 From: Thomas Lambert Date: Tue, 2 May 2023 13:02:34 +0200 Subject: [PATCH] fix: use vim.fn.system for image paste (#131, #241) --- lua/telekasten.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index e421fd5..87c33ec 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -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