Vim icon indicating copy to clipboard operation
Vim copied to clipboard

`:read` does not always use correct file

Open ascii78 opened this issue 4 years ago • 4 comments

Describe the bug :read should use correct current path when importing file , currently the behaviour is different on both windows and remote-ssh

To Reproduce

on windows:

  1. open a folder
  2. check with ctrl-g what the current directory is
  3. open a file in that folder
  4. "import" another file from that folder at the cursor with :r filename (relative)
  5. error is: "CommandLine: Error executing cmd=r filename. err=Error: ENOENT: no such file or directory, open 'C:\Program Files\Microsoft VS Code\filename'."
  6. so, doesn't seem to use current directory, however:
  7. use an absolute path, everything works.

on windows with remote-ssh to linux

  1. open a folder
  2. check with ctrl-g what the current directory is
  3. open a file in that folder
  4. "import" another file from that folder at the cursor with :r filename (relative path, and completion completes on linux as expected), however
  5. error is: "CommandLine: Error executing cmd=r filename. err=Error: ENOENT: no such file or directory, open 'C:\Program Files\Microsoft VS Code\filename'." (searches with local relative path)
  6. "import" another file from that folder at the cursor with :r filename (absolute path, and completion completes on linux as expected)
  7. error is: "CommandLine: Error executing cmd=r filename. err=Error: ENOENT: no such file or directory, open 'C:\home\username\filename
  8. use of an absolute does not work since "C:" is inserted.
:r working relative absolute
windows no yes
remote-ssh no no

Expected behavior :read should use correct current path when importing file

Screenshots If applicable, add screenshots to help explain your problem. If remapping-related, please attach log output: https://github.com/VSCodeVim/Vim#debugging-remappings.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.20.3
  • VSCode version: 1.51.1
  • OS: Windows

Additional context Add any other context about the problem here.

ascii78 avatar May 31 '21 14:05 ascii78

I have the same issue with both MacOS and Windows when connecting to Remote-SSH (or Remote-<Anything> for that matter). It seems VSCodeVim isn't aware of the local/remote context. Is there a plan to add support for executing :read file or :read !cmdline in a remote context?

levzlotnik avatar Aug 24 '21 04:08 levzlotnik

I can try to look into this issue in my spare time over the next few days. I'm not sure about the remote part of it, but I am looking into the current working directory part. I'll iron out some edge cases, test on different platforms, and hopefully put up a PR soon.

avborup avatar Aug 28 '21 10:08 avborup

I have the same issue. The problem appears to be that under Remote-SSH, :read reads from the local file system not the remote one.

geertj avatar Mar 29 '22 08:03 geertj

Commenting to say this issue still exists... would really appreciate a fix!

Tridecatrix avatar Sep 02 '25 04:09 Tridecatrix