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

Incorrect file copied message when a file was actually not copy #37

Open
miguelmoraperea opened this issue Dec 29, 2021 · 2 comments · May be fixed by nvim-lua/plenary.nvim#297
Open

Incorrect file copied message when a file was actually not copy #37

miguelmoraperea opened this issue Dec 29, 2021 · 2 comments · May be fixed by nvim-lua/plenary.nvim#297
Labels
bug Something isn't working

Comments

@miguelmoraperea
Copy link
Contributor

Description

Currently telescope-file-browser.nvim does not support copying a file to another directory other than cwd.

If a user tries to copy a file to another directory, the file is not copied, but the user gets the following message:

/example/path/to/file has been copied!

Which is an incorrect and misleading message, the file in fact was never copied.

Neovim version

NVIM v0.7.0-dev+792-gc46f7caad
Build type: RelWithDebInfo

Operating system and version

Ubuntu 20.04

Steps to reproduce

  1. Start to copy a file
  2. When prompt: "Copying existing file or folder within original directory, please provide a new file or folder name:" edit the file path to another directory, other than cwd.
  3. The file will not be copied (as expected) but the user will get the following message "[file] has been copied!".

Expected behavior

When copying a file outside the original directory, the message to the user should be: "[file] has not been copied".

Actual behavior

When copying a file outside the original directory, the message currently is: "[file] has been copied!", which is incorrect.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          'nvim-telescope/telescope-file-browser.nvim',
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('file_browser')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
@miguelmoraperea miguelmoraperea added the bug Something isn't working label Dec 29, 2021
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 29, 2021
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.
@fdschmidt93
Copy link
Member

fdschmidt93 commented Dec 29, 2021

Currently telescope-file-browser.nvim does not support copying a file to another directory other than cwd.

I've just tried it. For me it works so long as the target folder exists. Could you please confirm that?

If that's the case, then the issue would then be plenary having to support parents = true in Path:copy for files I think.

@miguelmoraperea
Copy link
Contributor Author

@fdschmidt93 That is correct, if the folder exists, the file is successfully copied.

I agree, this part needs to be handled in plenary with your pull request, you beat me to it :), but in my opinion, we should still make sure we print the correct message to the user, essentially I think we need both pull requests.

miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 29, 2021
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.
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 31, 2021
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.
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 31, 2021
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.
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 31, 2021
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 31, 2021
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.
miguelmoraperea added a commit to miguelmoraperea/telescope-file-browser.nvim that referenced this issue Dec 31, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants