vim-patch:1487947: runtime(netrw): glob() on windows fails with [] in directory name (#29324)

fixes: vim/vim#14952
closes: vim/vim#14991

1487947fb6

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2024-06-14 05:48:37 +08:00 committed by GitHub
parent 6b022f9d8b
commit 4a24940980
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,7 @@
" 2024 May 10 by Vim Project: recursively delete directories by default " 2024 May 10 by Vim Project: recursively delete directories by default
" 2024 May 13 by Vim Project: prefer scp over pscp " 2024 May 13 by Vim Project: prefer scp over pscp
" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952)
" Former Maintainer: Charles E Campbell " Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@ -5756,16 +5757,20 @@ fun! s:NetrwGlob(direntry,expr,pare)
let filelist= w:netrw_treedict[a:direntry] let filelist= w:netrw_treedict[a:direntry]
endif endif
let w:netrw_liststyle= keep_liststyle let w:netrw_liststyle= keep_liststyle
elseif v:version > 704 || (v:version == 704 && has("patch656"))
let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1,1)
if a:pare
let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")')
endif
else else
let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1) let path= s:ComposePath(fnameescape(a:direntry),a:expr)
if a:pare if has("win64")
let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') " escape [ so it is not detected as wildcard character, see :h wildcard
endif let path= substitute(path, '[', '[[]', 'g')
endif
if v:version > 704 || (v:version == 704 && has("patch656"))
let filelist= glob(path,0,1,1)
else
let filelist= glob(path,0,1)
endif
if a:pare
let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")')
endif
endif endif
" call Dret("s:NetrwGlob ".string(filelist)) " call Dret("s:NetrwGlob ".string(filelist))
return filelist return filelist