mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 03:53:47 -05:00
Push diff filtering down to shell.
This should make things a little more efficient on the basis of minimising the amount of data flowing up.
This commit is contained in:
@@ -68,7 +68,8 @@ endfunction
|
|||||||
" Diff processing {{{
|
" Diff processing {{{
|
||||||
|
|
||||||
function! s:run_diff()
|
function! s:run_diff()
|
||||||
let cmd = 'git diff --no-ext-diff -U0 ' . shellescape(s:current_file())
|
let cmd = 'git diff --no-ext-diff -U0 ' . shellescape(s:current_file()) .
|
||||||
|
\ ' | grep -e "^@@ "'
|
||||||
let diff = system(s:command_in_directory_of_current_file(cmd))
|
let diff = system(s:command_in_directory_of_current_file(cmd))
|
||||||
return diff
|
return diff
|
||||||
endfunction
|
endfunction
|
||||||
@@ -77,14 +78,12 @@ function! s:parse_diff(diff)
|
|||||||
let hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
|
let hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
|
||||||
let hunks = []
|
let hunks = []
|
||||||
for line in split(a:diff, '\n')
|
for line in split(a:diff, '\n')
|
||||||
if line =~ '^@@\s'
|
|
||||||
let matches = matchlist(line, hunk_re)
|
let matches = matchlist(line, hunk_re)
|
||||||
let from_line = str2nr(matches[1])
|
let from_line = str2nr(matches[1])
|
||||||
let from_count = (matches[2] == '') ? 1 : str2nr(matches[2])
|
let from_count = (matches[2] == '') ? 1 : str2nr(matches[2])
|
||||||
let to_line = str2nr(matches[3])
|
let to_line = str2nr(matches[3])
|
||||||
let to_count = (matches[4] == '') ? 1 : str2nr(matches[4])
|
let to_count = (matches[4] == '') ? 1 : str2nr(matches[4])
|
||||||
call add(hunks, [from_line, from_count, to_line, to_count])
|
call add(hunks, [from_line, from_count, to_line, to_count])
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
return hunks
|
return hunks
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user