justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.18k stars 64 forks source link

Get directory listing with globpath #184

Closed pavoljuhas closed 4 years ago

pavoljuhas commented 4 years ago

Fix dirvish for auto-mounted paths where mount root does not glob.

Problem: vim glob() does not match in subdirectories of some auto mounted paths, for example, in /home/autouser/docs/. This is probably because autouser does not glob in /home/.

Solution: use globpath instead of glob to do glob expansion only in leaf directory.

pavoljuhas commented 4 years ago

ping @justinmk - let me know if there are any questions about this.

justinmk commented 4 years ago

Problem: vim glob() does not match in subdirectories of some auto mounted paths, for example, in /home/autouser/docs/. This is probably because autouser does not glob in /home/.

I don't totally understand this. Do you have a reference for this (doc, Vim issue, mailing list discussion)?

pavoljuhas commented 4 years ago

Problem: vim glob() does not match in subdirectories of some auto mounted paths, for example, in /home/autouser/docs/. This is probably because autouser does not glob in /home/.

I don't totally understand this. Do you have a reference for this (doc, Vim issue, mailing list discussion)?

After more testing I found the problem happens whenwildignorecase is set. On my system ls /home does not show automounted user directories, but they can be cd-ed to. I suspect wic makes glob() expand [aA][uU][tT][oO][uU][sS][eE][rR] which does not match the listing of /home. The reason globpath seemed to help is because it does not use wic (which glob does - https://github.com/vim/vim/blob/4da7a259f6b28a4f855a6fa7d0ede5e038600154/src/filepath.c#L1192-L1193).

The wic is causing problems also with current master where it merges icase-equal directories.

mkdir /tmp/a /tmp/A
touch /tmp/a/a.txt /tmp/A/b.txt
vim -i NONE -U NONE -N -c 'set wic' -c 'Dirvish /tmp/a'

b.txt
a.txt

@justinmk - are you OK with changing this PR to use the original s:globlist, but with unset wic for the glob call?

justinmk commented 4 years ago

The reason globpath seemed to help is because it does not use wic (which glob does - https://github.com/vim/vim/blob/4da7a259f6b28a4f855a6fa7d0ede5e038600154/src/filepath.c#L1192-L1193).

...sure enough, from :help glob() :

Unless the optional {nosuf} argument is given and is |TRUE|, the 'suffixes' and 'wildignore' options apply. ... 'wildignorecase' always applies.

classic Vim.

are you OK with changing this PR to use the original s:globlist, but with unset wic for the glob call?

Would rather use globpath() than setting/unsetting an option. Is there any disadvantage to globpath()?

pavoljuhas commented 4 years ago

Would rather use globpath() than setting/unsetting an option. Is there any disadvantage to globpath()?

Does not seem so. globpath() needs an extra escape for , otherwise it should be similar to glob(). I will get to this over the weekend.

pavoljuhas commented 4 years ago

Here is the next iteration which keeps path escapes from master. I have added additional escapes to prevent extra expansion for

justinmk commented 4 years ago

Thank you for fixing this! Nasty bug.