mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Handle quickfix autocmd changing buffer
To keep things fast we turn off gitgutter in the current buffer during quickfix commands, e.g. :vimgrep, and turn it back on afterwards. However the user may have a quickfix autocmd which makes a different buffer the current one, e.g. :cwindow. Previously this caused an error because gitgutter expected the current buffer to remain current; now we explicitly enable the original current buffer. Fixes #904.
This commit is contained in:
@@ -341,8 +341,18 @@ augroup gitgutter
|
|||||||
autocmd BufFilePre * call s:on_buffilepre(expand('<abuf>'))
|
autocmd BufFilePre * call s:on_buffilepre(expand('<abuf>'))
|
||||||
autocmd BufFilePost * call s:on_buffilepost(expand('<abuf>'))
|
autocmd BufFilePost * call s:on_buffilepost(expand('<abuf>'))
|
||||||
|
|
||||||
autocmd QuickFixCmdPre *vimgrep* let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
|
autocmd QuickFixCmdPre *vimgrep*
|
||||||
autocmd QuickFixCmdPost *vimgrep* if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
|
\ if gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') |
|
||||||
|
\ let s:gitgutter_was_enabled = expand('<abuf>') |
|
||||||
|
\ else |
|
||||||
|
\ let s:gitgutter_was_enabled = 0 |
|
||||||
|
\ endif |
|
||||||
|
\ GitGutterBufferDisable
|
||||||
|
autocmd QuickFixCmdPost *vimgrep*
|
||||||
|
\ if s:gitgutter_was_enabled |
|
||||||
|
\ call gitgutter#buffer_enable(s:gitgutter_was_enabled) |
|
||||||
|
\ endif |
|
||||||
|
\ unlet s:gitgutter_was_enabled
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user