From 3ea6924aace91ab3b6878ec5a7b9b6e28b242f5f Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 2 Sep 2016 09:30:03 +0300 Subject: [PATCH] Bug fix: further relax syntastic#util#fname2buf(). --- autoload/syntastic/util.vim | 24 +++++++++++++++++++----- plugin/syntastic.vim | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index 2af3cf37..34318770 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -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 diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 138a653b..1d35cb5d 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -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