Commit
relates to #1099
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ type Block struct { | |
ansi *ansiUtils | ||
activeSegment *Segment | ||
previousActiveSegment *Segment | ||
activeBackground string | ||
activeForeground string | ||
} | ||
|
||
func (b *Block) init(env environmentInfo, writer colorWriter, ansi *ansiUtils) { | ||
|
@@ -126,7 +128,7 @@ func (b *Block) getPowerlineColor(foreground bool) string { | |
return b.previousActiveSegment.background() | ||
} | ||
if b.activeSegment.Style == Diamond && len(b.activeSegment.LeadingDiamond) == 0 { | ||
return b.activeSegment.background() | ||
return b.activeBackground | ||
} | ||
if !foreground && b.activeSegment.Style != Powerline { | ||
return Transparent | ||
|
@@ -138,6 +140,9 @@ func (b *Block) getPowerlineColor(foreground bool) string { | |
} | ||
|
||
func (b *Block) renderSegmentText(text string) { | ||
b.activeBackground = b.activeSegment.background() | ||
b.activeForeground = b.activeSegment.foreground() | ||
b.writer.setColors(b.activeBackground, b.activeForeground) | ||
switch b.activeSegment.Style { | ||
case Plain: | ||
b.renderPlainSegment(text) | ||
|
@@ -147,11 +152,11 @@ func (b *Block) renderSegmentText(text string) { | |
b.renderPowerLineSegment(text) | ||
} | ||
b.previousActiveSegment = b.activeSegment | ||
b.writer.setParentColors(b.activeSegment.background(), b.activeSegment.foreground()) | ||
b.writer.setParentColors(b.activeBackground, b.activeForeground) | ||
} | ||
|
||
func (b *Block) renderPowerLineSegment(text string) { | ||
b.writePowerLineSeparator(b.activeSegment.background(), b.getPowerlineColor(true), false) | ||
b.writePowerLineSeparator(b.activeBackground, b.getPowerlineColor(true), false) | ||
b.renderText(text) | ||
} | ||
|
||
|
@@ -160,7 +165,7 @@ func (b *Block) renderPlainSegment(text string) { | |
} | ||
|
||
func (b *Block) renderDiamondSegment(text string) { | ||
background := b.activeSegment.background() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JanDeDobbeleer
Author
Owner
|
||
background := b.activeBackground | ||
if background == Inherit { | ||
background = b.previousActiveSegment.background() | ||
} | ||
|
@@ -170,12 +175,10 @@ func (b *Block) renderDiamondSegment(text string) { | |
} | ||
|
||
func (b *Block) renderText(text string) { | ||
bg := b.activeSegment.background() | ||
fg := b.activeSegment.foreground() | ||
defaultValue := " " | ||
b.writer.write(bg, fg, b.activeSegment.getValue(Prefix, defaultValue)) | ||
b.writer.write(bg, fg, text) | ||
b.writer.write(bg, fg, b.activeSegment.getValue(Postfix, defaultValue)) | ||
b.writer.write(b.activeBackground, b.activeForeground, b.activeSegment.getValue(Prefix, defaultValue)) | ||
b.writer.write(b.activeBackground, b.activeForeground, text) | ||
b.writer.write(b.activeBackground, b.activeForeground, b.activeSegment.getValue(Postfix, defaultValue)) | ||
} | ||
|
||
func (b *Block) debug() (int, []*SegmentTiming) { | ||
|
@@ -205,7 +208,7 @@ func (b *Block) debug() (int, []*SegmentTiming) { | |
b.activeSegment = segment | ||
b.renderSegmentText(segmentTiming.stringValue) | ||
if b.activeSegment.Style == Powerline { | ||
b.writePowerLineSeparator(Transparent, b.activeSegment.background(), true) | ||
b.writePowerLineSeparator(Transparent, b.activeBackground, true) | ||
} | ||
segmentTiming.stringValue = b.writer.string() | ||
b.writer.reset() | ||
|
I have an issue with this change. I have a custom theme and the last diamond segment of the left prompt was rendered like this:
and now:
If I revert only this line, all tests are successfull and my current theme is still working.
https://gist.github.com/lnu/191c4e726468b0f7ad8899feb2192ee2#file-jandedobbeleer_custom-json