mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Prevent buffer numbers from rapidly increasing.
Instead of creating two new temporary files every time a realtime diff is performed, reuse the same two temporary files (per file extension). This stops the plugin using hundreds of different temporary files. Since the plugin now only uses a handful of temporary files we do not need to wipeout the unlisted buffer created by vim for each index-blob's temporary file. In turn this means vim no longer needs hundreds of unlisted buffers, so the next-available-buffer-number stays at sensible levels. See #297.
This commit is contained in:
@@ -11,6 +11,9 @@ let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
|
||||
|
||||
let s:fish = &shell =~# 'fish'
|
||||
|
||||
let s:temp_index = tempname()
|
||||
let s:temp_buffer = tempname()
|
||||
|
||||
" Returns a diff of the buffer.
|
||||
"
|
||||
" The way to get the diff depends on whether the buffer is saved or unsaved.
|
||||
@@ -61,8 +64,8 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
|
||||
|
||||
if a:realtime
|
||||
let blob_name = ':'.gitgutter#utility#shellescape(gitgutter#utility#file_relative_to_repo_root())
|
||||
let blob_file = tempname()
|
||||
let buff_file = tempname()
|
||||
let blob_file = s:temp_index
|
||||
let buff_file = s:temp_buffer
|
||||
let extension = gitgutter#utility#extension()
|
||||
if !empty(extension)
|
||||
let blob_file .= '.'.extension
|
||||
@@ -118,7 +121,6 @@ function! gitgutter#diff#run_diff(realtime, use_external_grep)
|
||||
if a:realtime
|
||||
call delete(blob_file)
|
||||
call delete(buff_file)
|
||||
execute 'keepalt silent! bwipeout' buff_file
|
||||
endif
|
||||
|
||||
if gitgutter#utility#shell_error()
|
||||
|
||||
Reference in New Issue
Block a user