Skip to content

Commit da0c27e

Browse files
authored
s:list_dir(): fix: 'wildignorecase' affects directory listing #184
glob() is affected by 'wildignorecase' even when suffix=1 is given. This is a documented behavior. globpath() is _not_ afflicted by this funny quirk, so use it instead. Also escape more special chars: - , path separator in globpath() - ; upward search syntax in 'path' - *? globing of the 'path' value
1 parent 4bc6add commit da0c27e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

autoload/dirvish.vim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ function! s:parent_dir(dir) abort
4242
endfunction
4343

4444
if v:version > 703
45-
function! s:globlist(pat) abort
46-
return glob(a:pat, !s:suf(), 1)
45+
function! s:globlist(dir_esc, pat) abort
46+
return globpath(a:dir_esc, a:pat, !s:suf(), 1)
4747
endfunction
4848
else "Vim 7.3 glob() cannot handle filenames containing newlines.
49-
function! s:globlist(pat) abort
50-
return split(glob(a:pat, !s:suf()), "\n")
49+
function! s:globlist(dir_esc, pat) abort
50+
return split(globpath(a:dir_esc, a:pat, !s:suf()), "\n")
5151
endfunction
5252
endif
5353

5454
function! s:list_dir(dir) abort
55-
" Escape for glob().
56-
let dir_esc = escape(substitute(a:dir,'\[','[[]','g'),'{}^$\')
57-
let paths = s:globlist(dir_esc.'*')
58-
"Append dot-prefixed files. glob() cannot do both in 1 pass.
59-
let paths = paths + s:globlist(dir_esc.'.[^.]*')
55+
" Escape for globpath().
56+
let dir_esc = escape(substitute(a:dir,'\[','[[]','g'), ',;*?{}^$\')
57+
let paths = s:globlist(dir_esc, '*')
58+
"Append dot-prefixed files. globpath() cannot do both in 1 pass.
59+
let paths = paths + s:globlist(dir_esc, '.[^.]*')
6060

6161
if get(g:, 'dirvish_relative_paths', 0)
6262
\ && a:dir != s:parent_dir(getcwd()) "avoid blank CWD

0 commit comments

Comments
 (0)