vifm / vifm.vim

Vim plugin that allows use of vifm as a file picker
335 stars 19 forks source link

Resolve filename when opening files. #91

Closed PhilRunninger closed 1 year ago

PhilRunninger commented 1 year ago

This pull request fixes a bug I discovered on Windows when opening multiple files from a symbolically linked folder. To create such a link I used this Powershell command with Admin privileges:

New-Item -ItemType SymbolicLink -Path "C:\Users\Phil\.config\nvim" -Target "C:\Users\Phil\AppData\Local\nvim"

When opening a couple files at once from the ~\nvim directory, vifm.vim was giving me this error:

Error detected while processing function 6[13]..<SNR>32_HandleRunResults:
line 86:
E94: No matching buffer for {filename redacted}

When this block of code (https://github.com/vifm/vifm.vim/blob/master/plugin/vifm.vim#L366-L371) runs, it starts with forward slashes from vifm, but the resolve function changes them to backslashes, thus not matching the buffer name.

If the comment is to believed, resolve() is necessary, so it should also be used when opening the files. That is what this PR changes.

xaizek commented 1 year ago

Thanks. It might be that Vim's behaviour has changed. I think there were cases when symbolic links were resolved automatically on adding files or it's the weirdness which happens when you open the same file under two different paths.

PhilRunninger commented 1 year ago

Oh, I left out an important point that was somewhat implied in my New-Item snippet. That is: I'm using Neovim. I don't expect any surprises, but I didn't test this on Vim. I did test it on my MacBook, and it works there, so I suspect all Linuxes will be okay too.

xaizek commented 1 year ago

The issue seems to appear in Vim on Windows as well and is addressed by your change. Thanks again.