mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-10 04:23:46 -05:00
Dedup buffer lists to avoid unnecessary work.
This commit is contained in:
@@ -3,7 +3,7 @@ let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ?
|
|||||||
" Primary functions {{{
|
" Primary functions {{{
|
||||||
|
|
||||||
function! gitgutter#all() abort
|
function! gitgutter#all() abort
|
||||||
for buffer_id in tabpagebuflist()
|
for buffer_id in gitgutter#utility#dedup(tabpagebuflist())
|
||||||
let file = expand('#' . buffer_id . ':p')
|
let file = expand('#' . buffer_id . ':p')
|
||||||
if !empty(file)
|
if !empty(file)
|
||||||
call gitgutter#process_buffer(buffer_id, 0)
|
call gitgutter#process_buffer(buffer_id, 0)
|
||||||
@@ -69,7 +69,7 @@ function! gitgutter#disable() abort
|
|||||||
call extend(buflist, tabpagebuflist(i + 1))
|
call extend(buflist, tabpagebuflist(i + 1))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for buffer_id in buflist
|
for buffer_id in gitgutter#utility#dedup(buflist)
|
||||||
let file = expand('#' . buffer_id . ':p')
|
let file = expand('#' . buffer_id . ':p')
|
||||||
if !empty(file)
|
if !empty(file)
|
||||||
call gitgutter#utility#set_buffer(buffer_id)
|
call gitgutter#utility#set_buffer(buffer_id)
|
||||||
|
|||||||
@@ -164,6 +164,12 @@ function! gitgutter#utility#highlight_name_for_change(text) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Dedups list in-place.
|
||||||
|
" Assumes list has no empty entries.
|
||||||
|
function! gitgutter#utility#dedup(list)
|
||||||
|
return filter(sort(a:list), 'index(a:list, v:val, v:key + 1) == -1')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#utility#strip_trailing_new_line(line) abort
|
function! gitgutter#utility#strip_trailing_new_line(line) abort
|
||||||
return substitute(a:line, '\n$', '', '')
|
return substitute(a:line, '\n$', '', '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user