Fix bug in realtime diff of non-current buffer.

This bug meant that a realtime diff of a buffer which wasn't the current
one -- which happens during GitGutterAll() -- diffed the staged version
of the buffer against the current buffer's contents instead of the
buffer's contents.
This commit is contained in:
Andy Stewart
2014-01-27 14:51:19 +01:00
parent 072846e945
commit 5485c37b38
2 changed files with 12 additions and 9 deletions

View File

@@ -25,15 +25,7 @@ function! diff#run_diff(realtime, use_external_grep)
let cmd = utility#escape(cmd)
if a:realtime
if &fileformat ==# "dos"
let eol = "\r\n"
elseif &fileformat ==# "mac"
let eol = "\r"
else
let eol = "\n"
endif
let buffer_contents = join(getline(1, '$'), eol) . eol
let diff = system(utility#command_in_directory_of_file(cmd), buffer_contents)
let diff = system(utility#command_in_directory_of_file(cmd), utility#buffer_contents())
else
let diff = system(utility#command_in_directory_of_file(cmd))
endif

View File

@@ -36,6 +36,17 @@ function! utility#save_last_seen_change(file)
call setbufvar(a:file, 'gitgutter_last_tick', getbufvar(a:file, 'changedtick'))
endfunction
function! utility#buffer_contents()
if &fileformat ==# "dos"
let eol = "\r\n"
elseif &fileformat ==# "mac"
let eol = "\r"
else
let eol = "\n"
endif
return join(getbufline(s:file, 1, '$'), eol) . eol
endfunction
" https://github.com/tpope/vim-dispatch/blob/9cdd05a87f8a47120335be03dfcd8358544221cd/autoload/dispatch/windows.vim#L8-L17
function! utility#escape(str)
if &shellxquote ==# '"'