mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-10 04:23:46 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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 ==# '"'
|
||||
|
||||
Reference in New Issue
Block a user