Skip to content

Commit

Permalink
Preserve alternate buffer when processing realtime diff.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Mar 10, 2015
1 parent a86a32c commit 3420cbf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/gitgutter/diff.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
let buff_file .= '.'.extension
endif
let cmd .= 'git show '.blob_name.' > '.blob_file.' && '
execute 'silent write' buff_file
execute 'keepalt silent write' buff_file
endif

let cmd .= 'git diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '
Expand Down
5 changes: 5 additions & 0 deletions test/helper.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ function! DumpGitDiffStaged(filename)
call system('git diff --staged fixture.txt > '.a:filename.'.actual')
endfunction

function! Dump(text, filename)
let msg = type(a:text) == 1 ? split(a:text, '\n') : a:text
call writefile(msg, a:filename.'.actual', 'a')
endfunction

3 changes: 3 additions & 0 deletions test/keepAlt.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
buffer: fixture.txt
altbuffer:
altbuffer:
12 changes: 12 additions & 0 deletions test/testKeepAlt.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source helper.vim
call Setup()

enew
execute "normal! \<C-^>"
call Dump('buffer: '.bufname(''), 'keepAlt')
call Dump('altbuffer: '.bufname('#'), 'keepAlt')

normal ggx
doautocmd CursorHold
call Dump('altbuffer: '.bufname('#'), 'keepAlt')

0 comments on commit 3420cbf

Please sign in to comment.