fix(zsh): correctly align right block

resolves #4327
This commit is contained in:
Jan De Dobbeleer 2023-11-05 11:19:45 +01:00 committed by Jan De Dobbeleer
parent 250ea1249f
commit 0a598a99bb
2 changed files with 12 additions and 0 deletions

View file

@ -129,14 +129,18 @@ func (b *Block) RenderSegments() (string, int) {
if !segment.Enabled && segment.style() != Accordion { if !segment.Enabled && segment.style() != Accordion {
continue continue
} }
if colors, newCycle := cycle.Loop(); colors != nil { if colors, newCycle := cycle.Loop(); colors != nil {
cycle = &newCycle cycle = &newCycle
segment.colors = colors segment.colors = colors
} }
b.setActiveSegment(segment) b.setActiveSegment(segment)
b.renderActiveSegment() b.renderActiveSegment()
} }
b.writeSeparator(true) b.writeSeparator(true)
return b.writer.String() return b.writer.String()
} }

View file

@ -222,6 +222,14 @@ func (e *Engine) renderBlock(block *Block, cancelNewline bool) bool {
return false return false
} }
// in ZSH, RPROMPT is printed with a trailing space
// to ensure alignment, we need to print a space here
// see https://github.com/JanDeDobbeleer/oh-my-posh/issues/4327
if e.Env.Shell() == shell.ZSH {
text += " "
length++
}
space, OK := e.canWriteRightBlock(false) space, OK := e.canWriteRightBlock(false)
// we can't print the right block as there's not enough room available // we can't print the right block as there's not enough room available
if !OK { if !OK {