diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-07-31 12:54:28 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-07-31 17:33:13 +1000 |
commit | 117c0bd4f7adea7afb845107623b1b3d9b4e96fa (patch) | |
tree | 96cfe200a0a2f7aaef6cefdeb56a01cfddb78f95 /pkg/commands/patch | |
parent | 79848087bccd5c87af1dbb44a39753aad1346f8b (diff) |
simplify code a bit
Diffstat (limited to 'pkg/commands/patch')
-rw-r--r-- | pkg/commands/patch/patch_parser.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go index 66e100ece..12426a3df 100644 --- a/pkg/commands/patch/patch_parser.go +++ b/pkg/commands/patch/patch_parser.go @@ -98,35 +98,35 @@ func (l *PatchLine) render(selected bool, included bool) string { return coloredString(style.FgCyan, match[1], selected, included) + coloredString(theme.DefaultTextColor, match[2], selected, false) } - colorAttr := theme.DefaultTextColor + textStyle := theme.DefaultTextColor switch l.Kind { case PATCH_HEADER: - colorAttr = colorAttr.SetBold(true) + textStyle = textStyle.SetBold() case ADDITION: - colorAttr = colorAttr.SetColor(style.FgGreen) + textStyle = style.FgGreen case DELETION: - colorAttr = colorAttr.SetColor(style.FgRed) + textStyle = style.FgRed case COMMIT_SHA: - colorAttr = colorAttr.SetColor(style.FgYellow) + textStyle = style.FgYellow } - return coloredString(colorAttr, content, selected, included) + return coloredString(textStyle, content, selected, included) } -func coloredString(colorAttr style.TextStyle, str string, selected bool, included bool) string { +func coloredString(textStyle style.TextStyle, str string, selected bool, included bool) string { if selected { - colorAttr = colorAttr.SetColor(theme.SelectedRangeBgColor) + textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor) } if len(str) < 2 { - return colorAttr.Sprint(str) + return textStyle.Sprint(str) } - res := colorAttr.Sprint(str[:1]) + res := textStyle.Sprint(str[:1]) if included { - return res + colorAttr.SetColor(style.BgGreen).Sprint(str[1:]) + return res + textStyle.MergeStyle(style.BgGreen).Sprint(str[1:]) } - return res + colorAttr.Sprint(str[1:]) + return res + textStyle.Sprint(str[1:]) } func parsePatch(patch string) ([]int, []int, []*PatchLine) { |