diff --git a/autoload/syntastic/postprocess.vim b/autoload/syntastic/postprocess.vim index 65570d98..80fd7cf4 100644 --- a/autoload/syntastic/postprocess.vim +++ b/autoload/syntastic/postprocess.vim @@ -46,6 +46,25 @@ function! syntastic#postprocess#filterForeignErrors(errors) " {{{2 return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr('')) endfunction " }}}2 +" make sure line numbers are not past end of buffers +" XXX: this loads all referenced buffers in memory +function! syntastic#postprocess#guards(errors) " {{{2 + let buffers = syntastic#util#unique(map(filter(copy(a:errors), 'v:val["valid"]'), 'str2nr(v:val["bufnr"])')) + + let guards = {} + for b in buffers + let guards[b] = len(getbufline(b, 1, '$')) + endfor + + for e in a:errors + if e['valid'] && e['lnum'] > guards[e['bufnr']] + let e['lnum'] = guards[e['bufnr']] + endif + endfor + + return a:errors +endfunction " }}}2 + " }}}1 let &cpo = s:save_cpo diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index b32b2596..c14adc6d 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.5.0-3' +let g:syntastic_version = '3.5.0-6' lockvar g:syntastic_version " Sanity checks {{{1 diff --git a/syntax_checkers/javascript/eslint.vim b/syntax_checkers/javascript/eslint.vim index 96919c8f..f23eb73b 100644 --- a/syntax_checkers/javascript/eslint.vim +++ b/syntax_checkers/javascript/eslint.vim @@ -35,7 +35,8 @@ function! SyntaxCheckers_javascript_eslint_GetLocList() dict let loclist = SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'postprocess': ['guards'] }) for e in loclist let e['col'] += 1 diff --git a/syntax_checkers/less/lessc.vim b/syntax_checkers/less/lessc.vim index 9b5efa96..ce653f51 100644 --- a/syntax_checkers/less/lessc.vim +++ b/syntax_checkers/less/lessc.vim @@ -58,6 +58,7 @@ function! SyntaxCheckers_less_lessc_GetLocList() dict return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'postprocess': ['guards'], \ 'defaults': {'bufnr': bufnr(""), 'text': "Syntax error"} }) endfunction