Skip to content

Commit 5b963ea

Browse files
committed
Update pathogen.vim
1 parent 38f0c94 commit 5b963ea

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

autoload/pathogen.vim

+24-12
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ let s:done_bundles = ''
166166
function! pathogen#helptags() " {{{1
167167
let sep = pathogen#separator()
168168
for dir in pathogen#split(&rtp)
169-
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(glob(dir.sep.'doc'.sep.'*')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
169+
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
170170
helptags `=dir.'/doc'`
171171
endif
172172
endfor
@@ -180,6 +180,17 @@ function! pathogen#runtime_findfile(file,count) "{{{1
180180
return fnamemodify(findfile(a:file,rtp,a:count),':p')
181181
endfunction " }}}1
182182

183+
" Backport of fnameescape().
184+
function! pathogen#fnameescape(string) " {{{1
185+
if exists('*fnameescape')
186+
return fnameescape(a:string)
187+
elseif a:string ==# '-'
188+
return '\-'
189+
else
190+
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
191+
endif
192+
endfunction " }}}1
193+
183194
function! s:find(count,cmd,file,lcd) " {{{1
184195
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
185196
let file = pathogen#runtime_findfile(a:file,a:count)
@@ -188,9 +199,9 @@ function! s:find(count,cmd,file,lcd) " {{{1
188199
elseif a:lcd
189200
let path = file[0:-strlen(a:file)-2]
190201
execute 'lcd `=path`'
191-
return a:cmd.' '.fnameescape(a:file)
202+
return a:cmd.' '.pathogen#fnameescape(a:file)
192203
else
193-
return a:cmd.' '.fnameescape(file)
204+
return a:cmd.' '.pathogen#fnameescape(file)
194205
endif
195206
endfunction " }}}1
196207

@@ -211,23 +222,24 @@ function! s:Findcomplete(A,L,P) " {{{1
211222
let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
212223
let found = {}
213224
for path in pathogen#split(&runtimepath)
225+
let path = expand(path, ':p')
214226
let matches = split(glob(path.sep.pattern),"\n")
215227
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
216-
call map(matches,'v:val[strlen(path)+1:-1]')
228+
call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
217229
for match in matches
218230
let found[match] = 1
219231
endfor
220232
endfor
221233
return sort(keys(found))
222234
endfunction " }}}1
223235

224-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
225-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
226-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
227-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
228-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
229-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
230-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
231-
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
236+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
237+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
238+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
239+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
240+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
241+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
242+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
243+
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
232244

233245
" vim:set ft=vim ts=8 sw=2 sts=2:

0 commit comments

Comments
 (0)