Closed rbong closed 4 years ago
Vim uses resolved filenames
In what cases? I get these results in my tests:
[~]$ ls -l .bashrc .inputrc
lrwxrwxrwx 1 xaizek users 13 2013-06-01 22:12 .bashrc -> .files/bashrc
lrwxrwxrwx 1 xaizek users 14 2013-06-01 22:11 .inputrc -> .files/inputrc
[~]$ vim +'cd /' -p .bashrc .inputrc
:ls
1 %a "~/.bashrc" line 1017
2 a "~/.inputrc" line 0
call map(flist, 'resolve(fnameescape(v:val))')
This attempts to resolve an escaped path. The functions should be called in the opposite order.
In what cases?
It happens when editing files in symbolically linked directories. My mistake for not thinking of plain files.
The functions should be called in the opposite order.
You are right. And I believe that resolve
only needs to be called on the first file, since it's the only file that :buffer
is called on.
We will want something more like this:
let firstfile = resolve(fnamemodify(unescaped_firstfile, ':h'))
\ .'/'.fnamemodify(unescaped_firstfile, ':t')
execute 'buffer' fnameescape(fnamemodify(firstfile, ':.'))
I am doing more testing now.
I updated and tested with both linked files and directories with special characters in their names. In my tests I was able to call resolve()
after fnameescape()
without problems.
On 8.1.2291 I get E94: No matching buffer for ...
because resolve('link\ with\ spaces/file')
just returns link\ with\ spaces/file
for me.
@xaizek thanks, I knew there must have been a case that must have resulted in error but I didn't want to introduce more complexity without knowing for sure. I've moved things around now so that the unescaped filename is used. It unfortunately required touching more of the callback function, but now I've tested with:
*
, {
, +
) in filenamesThanks!
Vim uses resolved filenames, and so we must use the resolved file path when using commands like :buffer.
Gets an error when following links in some cases without this change.