Skip to content
Snippets Groups Projects
Commit a5ae0a5a authored by Andy Stewart's avatar Andy Stewart
Browse files

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.
parent 6620e5fb
Branches
Tags
No related merge requests found
......@@ -341,8 +341,18 @@ augroup gitgutter
autocmd BufFilePre * call s:on_buffilepre(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 QuickFixCmdPost *vimgrep* if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
autocmd QuickFixCmdPre *vimgrep*
\ 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
" }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment