From 4eef07b8e2738c0347ebf4c14eb87a7000f6b10f Mon Sep 17 00:00:00 2001 From: Greg Block Date: Sun, 14 Jun 2020 13:49:07 -0700 Subject: [PATCH 01/10] Add 'g:lightline#gitdiff#show_empty_indicators' option --- .../lightline/gitdiff/algorithms/word_diff_porcelain.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim b/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim index 3dd6cda..f7a1668 100644 --- a/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim +++ b/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim @@ -17,16 +17,17 @@ function! lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) abo let l:lines_modified = len(filter(copy(l:changes), { idx, val -> val ==# 'M' })) let l:ret = {} + let l:show_empty_indicators = exists('g:lightline#gitdiff#show_empty_indicators') && g:lightline#gitdiff#show_empty_indicators - if l:lines_added > 0 + if l:lines_added > 0 || l:show_empty_indicators let l:ret['A'] = l:lines_added endif - if l:lines_deleted > 0 + if l:lines_deleted > 0 || l:show_empty_indicators let l:ret['D'] = l:lines_deleted endif - if l:lines_modified > 0 + if l:lines_modified > 0 || l:show_empty_indicators let l:ret['M'] = l:lines_modified endif From bb6d315ce9e4f03cfe2d4462392925c0e2cb8114 Mon Sep 17 00:00:00 2001 From: Greg Block Date: Sun, 14 Jun 2020 13:53:26 -0700 Subject: [PATCH 02/10] Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9367688..7e6fe03 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,11 @@ provide your own. Take a look at the source of both functions for inspiration or consult me if you need help. I am happy to bundle additional faster and more feature-rich algorithms in the package. +You can show empty indicators (i.e. `A: 0 D: 0 M: 0`) in the following way: +```vim +let g:lightline#gitdiff#show_empty_indicators = 1 +``` + # How it works / performance In the background, `lightline#gitdiff#get()` calls `git --numstat` or `git From 6d3b9ba5dfafad8b0df62d7ff694b5eaabbe768d Mon Sep 17 00:00:00 2001 From: Greg Block Date: Mon, 15 Jun 2020 13:51:43 -0700 Subject: [PATCH 03/10] Update #write_calculation_to_cache to support show_all_indicators for all algorithms --- README.md | 1 + autoload/lightline/gitdiff.vim | 19 +++++++++++++++---- .../algorithms/word_diff_porcelain.vim | 17 +---------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7e6fe03..ab17561 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ or consult me if you need help. I am happy to bundle additional faster and more feature-rich algorithms in the package. You can show empty indicators (i.e. `A: 0 D: 0 M: 0`) in the following way: + ```vim let g:lightline#gitdiff#show_empty_indicators = 1 ``` diff --git a/autoload/lightline/gitdiff.vim b/autoload/lightline/gitdiff.vim index a8ae45b..c1ec1c3 100644 --- a/autoload/lightline/gitdiff.vim +++ b/autoload/lightline/gitdiff.vim @@ -34,12 +34,23 @@ endfunction function! lightline#gitdiff#write_calculation_to_cache(buffer, soft) abort if a:soft && has_key(g:lightline#gitdiff#cache, a:buffer) " b/c there is something in the cache already - return + return endif - let l:Calculation = get(g:, 'lightline#gitdiff#algorithm', - \ { buffer -> lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) }) - let g:lightline#gitdiff#cache[a:buffer] = l:Calculation(a:buffer) + let l:indicator_values = get(g:, 'lightline#gitdiff#algorithm', + \ { buffer -> lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) })(a:buffer) + + " If the user doesn't want to show empty indicators, + " then remove the empty indicators returned from the algorithm + if !get(g:, 'lightline#gitdiff#show_empty_indicators', 0) + for key in keys(l:indicator_values) + if l:indicator_values[key] == 0 + unlet l:indicator_values[key] + endif + endfor + endif + + let g:lightline#gitdiff#cache[a:buffer] = l:indicator_values endfunction " format() {{{1 returns the calculated changes of the current buffer in a diff --git a/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim b/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim index f7a1668..7a7f432 100644 --- a/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim +++ b/autoload/lightline/gitdiff/algorithms/word_diff_porcelain.vim @@ -16,22 +16,7 @@ function! lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) abo let l:lines_deleted = len(filter(copy(l:changes), { idx, val -> val ==# 'D' })) let l:lines_modified = len(filter(copy(l:changes), { idx, val -> val ==# 'M' })) - let l:ret = {} - let l:show_empty_indicators = exists('g:lightline#gitdiff#show_empty_indicators') && g:lightline#gitdiff#show_empty_indicators - - if l:lines_added > 0 || l:show_empty_indicators - let l:ret['A'] = l:lines_added - endif - - if l:lines_deleted > 0 || l:show_empty_indicators - let l:ret['D'] = l:lines_deleted - endif - - if l:lines_modified > 0 || l:show_empty_indicators - let l:ret['M'] = l:lines_modified - endif - - return l:ret + return { 'A': l:lines_added, 'D': l:lines_deleted, 'M': l:lines_modified} endfunction " get_diff_porcelain {{{1 returns the output of git's word-diff as list. The From ad34a070f58d413be68180a5ba6fe98853c65382 Mon Sep 17 00:00:00 2001 From: Greg Block Date: Mon, 15 Jun 2020 18:33:17 -0700 Subject: [PATCH 04/10] Add tests for 'show_empty_indicators' --- test/lightline-gitdiff.vader | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/lightline-gitdiff.vader b/test/lightline-gitdiff.vader index 09aa45e..fc926ff 100644 --- a/test/lightline-gitdiff.vader +++ b/test/lightline-gitdiff.vader @@ -1,2 +1,22 @@ Include (Algorithms): algorithm/parse_indicator_group.vader Include (Utils): utils/group_at.vader + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable): + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return no empty indicators): + AssertEqual {}, actual + +Execute(write_calculation_to_cache(): given g:lightline#gitdiff#show_empty_indicators == 0): + let g:lightline#gitdiff#show_empty_indicators = 0 + call lightline#gitdiff#write_calculation_to_cache(2, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[2] +Then (should return no empty indicators): + AssertEqual {}, actual + +Execute(write_calculation_to_cache(): given g:lightline#gitdiff#show_empty_indicators == 1): + let g:lightline#gitdiff#show_empty_indicators = 1 + call lightline#gitdiff#write_calculation_to_cache(2, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[2] +Then (should return all empty indicators): + AssertEqual {'A': 0, 'D': 0, 'M': 0}, actual From 67cc2ea8e4f6e1772ef89da74f68ae241e20c7b5 Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:01:18 -0700 Subject: [PATCH 05/10] Rename lightline#gitdiff#algorithm to LightlineGitDiffAlgorithm --- autoload/lightline/gitdiff.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/lightline/gitdiff.vim b/autoload/lightline/gitdiff.vim index c1ec1c3..5cdd315 100644 --- a/autoload/lightline/gitdiff.vim +++ b/autoload/lightline/gitdiff.vim @@ -37,7 +37,7 @@ function! lightline#gitdiff#write_calculation_to_cache(buffer, soft) abort return endif - let l:indicator_values = get(g:, 'lightline#gitdiff#algorithm', + let l:indicator_values = get(g:, 'LightlineGitDiffAlgorithm', \ { buffer -> lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) })(a:buffer) " If the user doesn't want to show empty indicators, @@ -73,7 +73,7 @@ endfunction " " In fact, an arbitrary number of changes can be supported. This depends on " the algorithm that is used for calculation -" (`g:lightline#gitdiff#algorithm`). However, this function takes only these +" (`g:LightlineGitDiffAlgorithm`). However, this function takes only these " types of changes into account b/c it only provides default indicators for " these types. If an algorithm does not support a particular type, this is not " an issue; if it supports more types than this function, the additional types From 1ac663a6a5c496cb1bd8f07be20c5c214c3f71ce Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:07:32 -0700 Subject: [PATCH 06/10] Add more show_empty_indicators tests --- test/lightline-gitdiff.vader | 190 +++++++++++++++++++++++++++++++++-- 1 file changed, 181 insertions(+), 9 deletions(-) diff --git a/test/lightline-gitdiff.vader b/test/lightline-gitdiff.vader index fc926ff..c909ae3 100644 --- a/test/lightline-gitdiff.vader +++ b/test/lightline-gitdiff.vader @@ -1,22 +1,194 @@ Include (Algorithms): algorithm/parse_indicator_group.vader Include (Utils): utils/group_at.vader -Execute(write_calculation_to_cache(): given no show_empty_indicators variable): +Before : + if exists('g:LightlineGitDiffAlgorithm') + unlet g:LightlineGitDiffAlgorithm + endif + +" no show_empty_indicators +Execute(write_calculation_to_cache(): given no show_empty_indicators variable and an empty result): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M':0 } } call g:lightline#gitdiff#write_calculation_to_cache(1, 0) let actual = get(g:, 'lightline#gitdiff#cache')[1] Then (should return no empty indicators): AssertEqual {}, actual -Execute(write_calculation_to_cache(): given g:lightline#gitdiff#show_empty_indicators == 0): +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with only added lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 1, 'D': 0, 'M': 0 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'A'): + AssertEqual { 'A': 1 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with only deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 1, 'M': 0 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'D'): + AssertEqual { 'D': 1 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with only modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M': 1 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'M'): + AssertEqual { 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with added and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 3, 'D': 0, 'M': 1 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'D' indicator): + AssertEqual { 'A': 3, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with deleted and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 2, 'M': 1 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'A' indicator): + AssertEqual { 'D': 2, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with added and deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 4, 'D': 5, 'M': 0 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'M' indicator): + AssertEqual { 'A': 4, 'D': 5 }, actual + +Execute(write_calculation_to_cache(): given no show_empty_indicators variable with added, deleted, and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 9, 'D': 10, 'M': 7 } } + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should not remove any indicators): + AssertEqual { 'A': 9, 'D': 10, 'M': 7 }, actual + +" show_empty_indicators variable == 0 +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with an empty result): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M':0 } } let g:lightline#gitdiff#show_empty_indicators = 0 - call lightline#gitdiff#write_calculation_to_cache(2, 0) - let actual = get(g:, 'lightline#gitdiff#cache')[2] + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] Then (should return no empty indicators): AssertEqual {}, actual -Execute(write_calculation_to_cache(): given g:lightline#gitdiff#show_empty_indicators == 1): +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with only added lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 1, 'D': 0, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'A'): + AssertEqual { 'A': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with only deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 1, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'D'): + AssertEqual { 'D': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with only modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators but 'M'): + AssertEqual { 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with added and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 3, 'D': 0, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'D' indicator): + AssertEqual { 'A': 3, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with deleted and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 2, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'A' indicator): + AssertEqual { 'D': 2, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with added and deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 4, 'D': 5, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove only the 'M' indicator): + AssertEqual { 'A': 4, 'D': 5 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 0 with added, deleted, and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 9, 'D': 10, 'M': 7 } } + let g:lightline#gitdiff#show_empty_indicators = 0 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should not remove any indicators): + AssertEqual { 'A': 9, 'D': 10, 'M': 7 }, actual + +" show_empty_indicators variable == 1 +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with an empty result): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M':0 } } let g:lightline#gitdiff#show_empty_indicators = 1 - call lightline#gitdiff#write_calculation_to_cache(2, 0) - let actual = get(g:, 'lightline#gitdiff#cache')[2] -Then (should return all empty indicators): - AssertEqual {'A': 0, 'D': 0, 'M': 0}, actual + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 0, 'D': 0, 'M':0 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with only added lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 1, 'D': 0, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should remove all indicators): + AssertEqual { 'A': 1, 'D': 0, 'M': 0 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with only deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 1, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 0, 'D': 1, 'M': 0 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with only modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 0, 'D': 0, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with added and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 3, 'D': 0, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 3, 'D': 0, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with deleted and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 2, 'M': 1 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 0, 'D': 2, 'M': 1 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with added and deleted lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 4, 'D': 5, 'M': 0 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 4, 'D': 5, 'M': 0 }, actual + +Execute(write_calculation_to_cache(): given the show_empty_indicators variable equals 1 with added, deleted, and modified lines): + let g:LightlineGitDiffAlgorithm = { -> { 'A': 9, 'D': 10, 'M': 7 } } + let g:lightline#gitdiff#show_empty_indicators = 1 + call g:lightline#gitdiff#write_calculation_to_cache(1, 0) + let actual = get(g:, 'lightline#gitdiff#cache')[1] +Then (should return all indicators): + AssertEqual { 'A': 9, 'D': 10, 'M': 7 }, actual From 3af337641c65dad051da6b4106812d0d35d0e1d3 Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:09:29 -0700 Subject: [PATCH 07/10] Change lightline#gitdiff#algorithm to LightlineGitDiffAlgorithm in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab17561..8330bb5 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ By default, the latter one is used because it allows to display modified lines. This resembles the default: ```vim -let g:lightline#gitdiff#algorithm = +let g:LightlineGitDiffAlgorithm = \ { buffer -> lightline#gitdiff#algorithms#word_diff_porcelain#calculate(buffer) } ``` From 2a3bd79cd5a30d6c79b7251461dac041b119d463 Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:13:56 -0700 Subject: [PATCH 08/10] Update numstat algorithm --- autoload/lightline/gitdiff/algorithms/numstat.vim | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/autoload/lightline/gitdiff/algorithms/numstat.vim b/autoload/lightline/gitdiff/algorithms/numstat.vim index 4fed527..6c36f2c 100644 --- a/autoload/lightline/gitdiff/algorithms/numstat.vim +++ b/autoload/lightline/gitdiff/algorithms/numstat.vim @@ -17,17 +17,5 @@ function! lightline#gitdiff#algorithms#numstat#calculate(buffer) abort return {} endif - let l:ret = {} - - " lines added - if l:stats[0] !=# '0' - let l:ret['A'] = l:stats[0] - endif - - " lines deleted - if l:stats[1] !=# '0' - let l:ret['D'] = l:stats[1] - endif - - return l:ret + return return { 'A': l:stats[0], 'D': l:stats[1] } endfunction From 33dcb622041d92dda69a008b2a0706237a9a99fc Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:25:30 -0700 Subject: [PATCH 09/10] Fix double return --- autoload/lightline/gitdiff/algorithms/numstat.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/lightline/gitdiff/algorithms/numstat.vim b/autoload/lightline/gitdiff/algorithms/numstat.vim index 6c36f2c..ae665c3 100644 --- a/autoload/lightline/gitdiff/algorithms/numstat.vim +++ b/autoload/lightline/gitdiff/algorithms/numstat.vim @@ -17,5 +17,5 @@ function! lightline#gitdiff#algorithms#numstat#calculate(buffer) abort return {} endif - return return { 'A': l:stats[0], 'D': l:stats[1] } + return { 'A': l:stats[0], 'D': l:stats[1] } endfunction From f592e8545d56314090fae72141a982a9b85452dd Mon Sep 17 00:00:00 2001 From: Greg Block Date: Tue, 16 Jun 2020 21:27:29 -0700 Subject: [PATCH 10/10] Cleanup comment --- test/lightline-gitdiff.vader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lightline-gitdiff.vader b/test/lightline-gitdiff.vader index c909ae3..b09c653 100644 --- a/test/lightline-gitdiff.vader +++ b/test/lightline-gitdiff.vader @@ -6,7 +6,7 @@ Before : unlet g:LightlineGitDiffAlgorithm endif -" no show_empty_indicators +" no show_empty_indicators variable Execute(write_calculation_to_cache(): given no show_empty_indicators variable and an empty result): let g:LightlineGitDiffAlgorithm = { -> { 'A': 0, 'D': 0, 'M':0 } } call g:lightline#gitdiff#write_calculation_to_cache(1, 0)