-
Notifications
You must be signed in to change notification settings - Fork 4
Add 'g:lightline#gitdiff#show_empty_indicators' option #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4eef07b
Add 'g:lightline#gitdiff#show_empty_indicators' option
gblock0 bb6d315
Update README
gblock0 6d3b9ba
Update #write_calculation_to_cache to support show_all_indicators for…
gblock0 ad34a07
Add tests for 'show_empty_indicators'
gblock0 aa1d408
Merge pull request #1 from gblock0/AddShowIndicatorsTest
gblock0 67cc2ea
Rename lightline#gitdiff#algorithm to LightlineGitDiffAlgorithm
gblock0 1ac663a
Add more show_empty_indicators tests
gblock0 3af3376
Change lightline#gitdiff#algorithm to LightlineGitDiffAlgorithm in
gblock0 2a3bd79
Update numstat algorithm
gblock0 33dcb62
Fix double return
gblock0 f592e85
Cleanup comment
gblock0 86e9c9f
Merge pull request #2 from gblock0/AddShowIndicatorsTest
gblock0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,194 @@ | ||
Include (Algorithms): algorithm/parse_indicator_group.vader | ||
Include (Utils): utils/group_at.vader | ||
|
||
Before : | ||
if exists('g:LightlineGitDiffAlgorithm') | ||
unlet g:LightlineGitDiffAlgorithm | ||
endif | ||
|
||
" 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) | ||
niklaas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let actual = get(g:, 'lightline#gitdiff#cache')[1] | ||
Then (should return no empty indicators): | ||
AssertEqual {}, actual | ||
|
||
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 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 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 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.