From 18837e117460fe45657d3a0dc37db6c3eb0e4a5f Mon Sep 17 00:00:00 2001 From: bhagwan Date: Thu, 16 Dec 2021 10:07:32 -0800 Subject: [PATCH] internal: wrap warning message from 'read_file_async' (closes #263) --- lua/fzf-lua/utils.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/fzf-lua/utils.lua b/lua/fzf-lua/utils.lua index 7db7ee5..e19c3c7 100644 --- a/lua/fzf-lua/utils.lua +++ b/lua/fzf-lua/utils.lua @@ -155,7 +155,11 @@ end M.read_file_async = function(filepath, callback) vim.loop.fs_open(filepath, "r", 438, function(err_open, fd) if err_open then - M.warn("We tried to open this file but couldn't. We failed with following error message: " .. err_open) + -- we must schedule this or we get + -- E5560: nvim_exec must not be called in a lua loop callback + vim.schedule(function() + M.warn(("Unable to open file '%s', error: %s"):format(filepath, err_open)) + end) return end vim.loop.fs_fstat(fd, function(err_fstat, stat)