Always use realtime diff when buffer is modified.

This was motivated by Vim regaining focus into a buffer with unsaved
changes, and the realtime diff being replaced with an out of date disk
diff.  With this commit the realtime diff will be run again.
This commit is contained in:
Andy Stewart
2013-12-07 14:42:45 +00:00
parent 6f760b077f
commit f2e794b484

View File

@@ -84,6 +84,10 @@ function! s:directory_of_file()
return shellescape(fnamemodify(s:file(), ':h')) return shellescape(fnamemodify(s:file(), ':h'))
endfunction endfunction
function! s:has_unsaved_changes(file)
return getbufvar(a:file, "&mod")
endfunction
" https://github.com/tpope/vim-dispatch/blob/9cdd05a87f8a47120335be03dfcd8358544221cd/autoload/dispatch/windows.vim#L8-L17 " https://github.com/tpope/vim-dispatch/blob/9cdd05a87f8a47120335be03dfcd8358544221cd/autoload/dispatch/windows.vim#L8-L17
function! s:escape(str) function! s:escape(str)
if &shellxquote ==# '"' if &shellxquote ==# '"'
@@ -455,7 +459,7 @@ function! GitGutter(file, ...)
call s:set_file(a:file) call s:set_file(a:file)
if s:is_active() if s:is_active()
call s:init() call s:init()
if a:0 == 1 if (a:0 == 1) || s:has_unsaved_changes(a:file)
let diff = s:run_diff(1) let diff = s:run_diff(1)
else else
let diff = s:run_diff(0) let diff = s:run_diff(0)