Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Incorrect file copied message (#37) #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lua/telescope/_extensions/file_browser/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that comes to mind here (referring to my other post), for instance are copying folders.

IIRC my plenary PR correctly, a folder would return a table of

{
  file_a.ext = bool,
  file_b.ext = bool,
  folder = { ... },
}

Hence, I think we'd be erroneously printing success, whenever one of the sub-files is copied improperly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out @fdschmidt93

I think you are onto something, but actually, we are not printing any message for copied folders.

I also noticed something interesting when copying files/folders, we are copying only the files/folders in the current dir and the first sub-dir down, all other deeper levels are recursively copied over, but we don't get a result for those file/directories after the first level down.

I need to take a closer look into this. I'll try to work on this sometime tomorrow.

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

Expand Down