Skip to content

Commit

Permalink
fix(engine): reset segments after write
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Jul 4, 2024
1 parent b97ea11 commit 51e4faf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/prompt/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Engine struct {
Env runtime.Environment
Plain bool

console strings.Builder
prompt strings.Builder
currentLineLength int
rprompt string
rpromptLength int
Expand All @@ -31,12 +31,12 @@ type Engine struct {
}

func (e *Engine) write(text string) {
e.console.WriteString(text)
e.prompt.WriteString(text)
}

func (e *Engine) string() string {
text := e.console.String()
e.console.Reset()
text := e.prompt.String()
e.prompt.Reset()
return text
}

Expand Down Expand Up @@ -323,6 +323,9 @@ func (e *Engine) renderBlockSegments(block *config.Block) (string, int) {

e.writeSeparator(true)

e.activeSegment = nil
e.previousActiveSegment = nil

return terminal.String()
}

Expand All @@ -348,6 +351,7 @@ func (e *Engine) setActiveSegment(segment *config.Segment) {

func (e *Engine) renderActiveSegment() {
e.writeSeparator(false)

switch e.activeSegment.ResolveStyle() {
case config.Plain, config.Powerline:
terminal.Write(color.Background, color.Foreground, e.activeSegment.Text)
Expand All @@ -365,6 +369,7 @@ func (e *Engine) renderActiveSegment() {
terminal.Write(color.Background, color.Foreground, e.activeSegment.Text)
}
}

e.previousActiveSegment = e.activeSegment

terminal.SetParentColors(e.previousActiveSegment.ResolveBackground(), e.previousActiveSegment.ResolveForeground())
Expand Down

0 comments on commit 51e4faf

Please sign in to comment.