Add 'g:lightline#gitdiff#show_empty_indicators' option#17
Add 'g:lightline#gitdiff#show_empty_indicators' option#17niklaas merged 12 commits intoniklaas:masterfrom
Conversation
|
Thanks a lot for your contribution. I'll take a look at it. |
There was a problem hiding this comment.
Thanks again for your changes. Please address the following suggestions (more detailed explanation below):
- Check for new option in
lightline#gitdiff#write_calculation_to_cache()(to support all algorithms) - Always return added, deleted and modified lines in
lightline#gitdiff#algorithms#word_diff_porcelain#calculate - Add unit tests for
show_empty_indicators
You only adapted algorithm word_diff_porcelain. There is another one called numstat in the same directory here:
So instead of checking for the option in word_diff_porcelain only, I would suggest checking between the following two expressions:
lightline-gitdiff/autoload/lightline/gitdiff.vim
Lines 40 to 42 in 0679231
This way we can guarantee that all current and all future algorithms will be supported.
This also requires changing word_diff_porcelain to always return added, deleted and modified lines -- even if there are none -- here
Please add additional unit tests that ensure that show_empty_indicators works as expected.
Would you mind adding these suggestions? This is quite a lot and I'm already very thankful for your contribution. Please tell me if you need any help.
|
Thanks for the feedback! I’ll take a look tonight and make the changes. |
|
I'll add tests for |
Add tests for 'show_empty_indicators'
|
Tests added and code updated! Let me know your thoughts! These were my first Vader tests, so let me know if you'd like them structured differently. |
niklaas
left a comment
There was a problem hiding this comment.
I'm sorry, this needs further changes. I you want to, you can open your branch so I can commit there directly. Otherwise feel free to apply and change the provided diffs.
Don't hesitate to ask further questions. At the moment I don't have a lot of time to spend on this plugin but I will answer eventually. 🙂
niklaas
left a comment
There was a problem hiding this comment.
And we would also need these additional changes to the other algorithm that is provided:
diff --git a/autoload/lightline/gitdiff/algorithms/numstat.vim b/autoload/lightline/gitdiff/algorithms/numstat.vim
index 4fed527..ae665c3 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 { 'A': l:stats[0], 'D': l:stats[1] }
endfunctionRename lightline#gitdiff#algorithm to LightlineGitDiffAlgorithm, update numstat.vim, and add tests
|
No worries at all! I really appreciate all the great feedback!
I've checked |
|
I really appreciate your contributions and thoughts. I’ll take a look at these throughout the day. |
niklaas
left a comment
There was a problem hiding this comment.
g:LightlineGitDiffAlgorithm makes much more sense. And thanks a lot for providing the unit tests. Your contribution greatly improves the quality of the plugin!
|
P.S.: Since the plugin seems to get a bit more attention, what do you think of #16 ? I'm wondering whether I should spend some time on that. |
|
🎉 thanks again! |
|
Happy to contribute! I'll take a look at #16 and add some thoughts. |
I like being able to see
A: 0 D: 0 M: 0, so this adds theg:lightline#gitdiff#show_empty_indicatorsoption to show 0 for the indicators if they would otherwise be empty.This is my first Vim script related PR, so let me know if you'd prefer things any changes.