From d97225f4b96a2ad0cf682147ec62c0e38df09d09 Mon Sep 17 00:00:00 2001 From: Miguel Mora Perea Date: Tue, 28 Dec 2021 23:27:51 -0800 Subject: [PATCH] fix: Incorrect file copied message (#37) When copying a file outside the original directory (cwd) the file is not copied, this is expected, but the user still gets the following message: [file] has been copied! This is incorrect, this commit fixes the issue by verifying the result status from the copy operation and prints the appropriate message '[file] has been copied!' or '[file] has not been copied' depending on whether the operation succeeded or not. --- .../_extensions/file_browser/actions.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/telescope/_extensions/file_browser/actions.lua b/lua/telescope/_extensions/file_browser/actions.lua index ee44c267..8d4d4615 100644 --- a/lua/telescope/_extensions/file_browser/actions.lua +++ b/lua/telescope/_extensions/file_browser/actions.lua @@ -295,12 +295,23 @@ fb_actions.copy_file = function(prompt_bufnr) end end if destination ~= "" then -- vim.fn.input may return "" on cancellation - file:copy { + local res = file:copy { destination = destination, recursive = true, parents = true, } - print(string.format("\n%s has been copied!", filename)) + + for key, value in pairs(res) do + if key.filename == destination then + local res_msg + if res[key] then + res_msg = string.format("\n%s has been copied!", filename) + else + res_msg = string.format("\n%s has not been copied", filename) + end + a.nvim_echo({ { res_msg } }, false, {}) + end + end end end