From 7ddee0a79c23ffa0978fc044fd6583e8c7a8f372 Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Tue, 21 Jul 2020 12:35:28 +0200 Subject: [PATCH] Return if pasting on root and remove continue. --- lua/lib/fs.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/lib/fs.lua b/lua/lib/fs.lua index e97de797..7bcf8aec 100644 --- a/lua/lib/fs.lua +++ b/lua/lib/fs.lua @@ -142,6 +142,7 @@ local function do_copy(source, destination) end local function do_paste(node, action_type, action_fn) + if node.name == '..' then return end local clip = clipboard[action_type] if #clip == 0 then return end @@ -170,17 +171,19 @@ local function do_paste(node, action_type, action_fn) for _, entry in ipairs(clip) do local dest = destination..'/'..entry.name local dest_stats = luv.fs_stat(dest) + local should_process = true if dest_stats then local ans = vim.fn.input(dest..' already exists, overwrite ? y/n: ') clear_prompt() - if not ans:match('^y') then goto continue end + should_process = ans:match('^y') end - local success, msg = action_fn(entry.absolute_path, dest) - if not success then - api.nvim_err_writeln('Could not '..action_type..' '..entry.absolute_path..' - '..msg) + if should_process then + local success, msg = action_fn(entry.absolute_path, dest) + if not success then + api.nvim_err_writeln('Could not '..action_type..' '..entry.absolute_path..' - '..msg) + end end - ::continue:: end clipboard[action_type] = {} return refresh_tree()