From 47a74903a46d754852a2fd41253c872080ffdf1b Mon Sep 17 00:00:00 2001 From: Cimbali Date: Sat, 30 Mar 2024 10:17:22 +0000 Subject: [PATCH] Compute changed lines with minimal diff options --- plugin/better-whitespace.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugin/better-whitespace.vim b/plugin/better-whitespace.vim index 3cd4e6a..85c2dfa 100644 --- a/plugin/better-whitespace.vim +++ b/plugin/better-whitespace.vim @@ -102,7 +102,7 @@ function! s:WhitespaceInit() endfunction " Diff command returning a space-separated list of ranges of new/modified lines (as first,last) -let s:diff_cmd=g:diff_binary.' -a --unchanged-group-format="" --old-group-format="" --new-group-format="%dF,%dL " --changed-group-format="%dF,%dL " ' +let s:diff_cmd=g:diff_binary.' -a' " Section: Actual work functions @@ -266,7 +266,10 @@ function! s:ChangedLines() redir => l:better_whitespace_changes_list silent! echo system(s:diff_cmd.' '.shellescape(expand('%')).' -', join(getline(1, line('$')), "\n") . "\n") redir END - return map(split(s:Trim(l:better_whitespace_changes_list), ' '), 'split(v:val, ",")') + " Get relevant lines (added/changed group headers) + let lines=filter(split(l:better_whitespace_changes_list, '\n'), 'match(v:val, "^[0-9,]*[ac][0-9,]*$") > -1') + " Extract first,last line info (repeat first,first if there’s only first line) + return map(map(lines, 'split(split(v:val, "[ac]")[1], ",")'), 'len(v:val) == 1 ? v:val + v:val : v:val') endif return [] endfunction