diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index 844a4ed9..eec3c0df 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -339,6 +339,21 @@ function! syntastic#util#stamp() abort " {{{2 return split( split(reltimestr(reltime(g:_SYNTASTIC_START)))[0], '\.' ) endfunction " }}}2 +let s:_wid_base = 'syntastic_' . getpid() . '_' . reltimestr(g:_SYNTASTIC_START) . '_' +let s:_wid_pool = 0 + +" Add unique IDs to windows +function! syntastic#util#setWids() abort " {{{2 + for tab in range(1, tabpagenr('$')) + for win in range(1, tabpagewinnr(tab, '$')) + if gettabwinvar(tab, win, 'syntastic_wid') ==# '' + call settabwinvar(tab, win, 'syntastic_wid', s:_wid_base . s:_wid_pool) + let s:_wid_pool += 1 + endif + endfor + endfor +endfunction " }}}2 + let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr') lockvar s:_str2float diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index c689b7d2..7c9efa14 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-47' +let g:_SYNTASTIC_VERSION = '3.7.0-48' lockvar g:_SYNTASTIC_VERSION " Sanity checks {{{1 @@ -163,6 +163,8 @@ let s:registry = g:SyntasticRegistry.Instance() let s:notifiers = g:SyntasticNotifiers.Instance() let s:modemap = g:SyntasticModeMap.Instance() +let s:_quit_pre = [] + " Commands {{{1 " @vimlint(EVL103, 1, a:cursorPos) @@ -259,7 +261,7 @@ endif if exists('##QuitPre') " QuitPre was added in Vim 7.3.544 augroup syntastic - autocmd QuitPre * call s:QuitPreHook() + autocmd QuitPre * call s:QuitPreHook(expand('', 1)) augroup END endif @@ -296,10 +298,15 @@ function! s:BufEnterHook() abort " {{{2 endif endfunction " }}}2 -function! s:QuitPreHook() abort " {{{2 - call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, - \ 'autocmd: QuitPre, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr(''))))) - let b:syntastic_skip_checks = get(b:, 'syntastic_skip_checks', 0) || !syntastic#util#var('check_on_wq') +function! s:QuitPreHook(fname) abort " {{{2 + let buf = bufnr(fnameescape(a:fname)) + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, 'autocmd: QuitPre, buffer ' . buf . ' = ' . string(a:fname)) + + if !syntastic#util#var('check_on_wq') + call syntastic#util#setWids() + call add(s:_quit_pre, buf . '_' . getbufvar(buf, 'changetick') . '_' . w:syntastic_wid) + endif + if get(w:, 'syntastic_loclist_set', 0) call SyntasticLoclistHide() endif @@ -636,12 +643,26 @@ function! s:_ignore_file(filename) abort " {{{2 return 0 endfunction " }}}2 +function! s:_is_quitting(buf) abort " {{{2 + let quitting = 0 + if exists('w:syntastic_wid') + let key = a:buf . '_' . getbufvar(a:buf, 'changetick') . '_' . w:syntastic_wid + let idx = index(s:_quit_pre, key) + if idx >= 0 + call remove(s:_quit_pre, idx) + let quitting = 1 + endif + endif + + return quitting +endfunction " }}}2 + " Skip running in special buffers function! s:_skip_file() abort " {{{2 let fname = expand('%', 1) - let skip = get(b:, 'syntastic_skip_checks', 0) || (&buftype !=# '') || - \ !filereadable(fname) || getwinvar(0, '&diff') || s:_ignore_file(fname) || - \ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions + let skip = s:_is_quitting(bufnr('%')) || get(b:, 'syntastic_skip_checks', 0) || + \ (&buftype !=# '') || !filereadable(fname) || getwinvar(0, '&diff') || + \ s:_ignore_file(fname) || fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions if skip call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '_skip_file: skipping checks') endif @@ -654,6 +675,9 @@ function! s:_explain_skip(filetypes) abort " {{{2 let why = [] let fname = expand('%', 1) + if s:_is_quitting(bufnr('%')) + call add(why, 'quitting buffer') + endif if get(b:, 'syntastic_skip_checks', 0) call add(why, 'b:syntastic_skip_checks set') endif