diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-05 18:21:09 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-05 19:22:01 +1100 |
commit | db8c398fa33c6240bb4deca08aa6b5553497ef64 (patch) | |
tree | 43a9e9327f3a5863d00a8651160a32ebbb528355 /pkg/commands | |
parent | 861bcc38be1f21b4b9d7a1e6a1530a01a45b4986 (diff) |
strip whitespace when there is nothing else
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/patch_manager.go | 9 | ||||
-rw-r--r-- | pkg/commands/patch_parser.go | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/pkg/commands/patch_manager.go b/pkg/commands/patch_manager.go index 3f0f0ac06..5191c2348 100644 --- a/pkg/commands/patch_manager.go +++ b/pkg/commands/patch_manager.go @@ -2,7 +2,6 @@ package commands import ( "sort" - "strings" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sirupsen/logrus" @@ -145,7 +144,13 @@ func (p *PatchManager) RenderEachFilePatch(plain bool) []string { } func (p *PatchManager) RenderAggregatedPatchColored(plain bool) string { - return strings.Join(p.RenderEachFilePatch(plain), "\n") + result := "" + for _, patch := range p.RenderEachFilePatch(plain) { + if patch != "" { + result += patch + "\n" + } + } + return result } func (p *PatchManager) GetFileStatus(filename string) int { diff --git a/pkg/commands/patch_parser.go b/pkg/commands/patch_parser.go index 06781c8cf..e88a43f32 100644 --- a/pkg/commands/patch_parser.go +++ b/pkg/commands/patch_parser.go @@ -194,7 +194,11 @@ func (p *PatchParser) Render(firstLineIndex int, lastLineIndex int, incLineIndic included := utils.IncludesInt(incLineIndices, index) renderedLines[index] = patchLine.render(selected, included) } - return strings.Join(renderedLines, "\n") + result := strings.Join(renderedLines, "\n") + if strings.TrimSpace(utils.Decolorise(result)) == "" { + return "" + } + return result } // GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line |