Bug fix: further relax syntastic#util#fname2buf().

This commit is contained in:
LCD 47 2016-09-02 09:30:03 +03:00
parent c946648974
commit 3ea6924aac
2 changed files with 20 additions and 6 deletions

View File

@ -272,20 +272,34 @@ function! syntastic#util#findGlobInParent(what, where) abort " {{{2
endfunction " }}}2
" Returns the buffer number of a filename
" @vimlint(EVL104, 1, l:old_shellslash)
function! syntastic#util#fname2buf(fname) abort " {{{2
" this is a best-effort attempt to escape file patterns (cf. :h file-pattern)
" XXX it fails for filenames containing something like \{2,3}
if exists('+shellslash')
" bufnr() can't cope with backslashes
let old_shellslash = &shellslash
let &shellslash = 1
let buf = bufnr(escape( fnamemodify(a:fname, ':p'), '\*?,{}[' ))
endif
" this is a best-effort attempt to escape file patterns (cf. :h file-pattern)
" XXX it fails for filenames containing something like \{2,3}
for md in [':~:.', ':~', ':p']
let buf = bufnr('^' . escape(fnamemodify(a:fname, md), '\*?,{}[') . '$')
if buf != -1
break
endif
endfor
if buf == -1
" XXX definitely wrong, but hope is the last thing to die :)
let buf = bufnr(fnamemodify(a:fname, ':p'))
endif
if exists('+shellslash')
let &shellslash = old_shellslash
else
let buf = bufnr(escape( fnamemodify(a:fname, ':p'), '\*?,{}[' ))
endif
return buf
endfunction " }}}2
" @vimlint(EVL104, 0, l:old_shellslash)
" Returns unique elements in a list
function! syntastic#util#unique(list) abort " {{{2

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-208'
let g:_SYNTASTIC_VERSION = '3.7.0-210'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1