Skip to content

Commit

Permalink
fix(segment): add to cache after rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Nov 7, 2024
1 parent 84d132e commit ce02759
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/config/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,11 @@ func (segment *Segment) Execute(env runtime.Environment) {
return
}

if shouldHideForWidth(segment.env, segment.MinWidth, segment.MaxWidth) {
if shouldHideForWidth(env, segment.MinWidth, segment.MaxWidth) {
return
}

if segment.writer.Enabled() {
segment.Enabled = true
env.TemplateCache().AddSegmentData(segment.Name(), segment.writer)
}
segment.Enabled = segment.writer.Enabled()
}

func (segment *Segment) Render() {
Expand All @@ -138,7 +135,8 @@ func (segment *Segment) Render() {
return
}

segment.writer.SetText(text)
segment.SetText(text)
segment.env.TemplateCache().AddSegmentData(segment.Name(), segment.writer)
segment.setCache()
}

Expand Down
10 changes: 5 additions & 5 deletions src/prompt/segments.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ func (e *Engine) writeSegments(out chan result, block *config.Block) {

results[res.index] = res.segment

name := res.segment.Name()
if !slices.Contains(executed, name) {
executed = append(executed, name)
}

segment := results[current]

for segment != nil {
Expand All @@ -80,6 +75,11 @@ func (e *Engine) writeSegments(out chan result, block *config.Block) {

current++
segment = results[current]

name := res.segment.Name()
if !slices.Contains(executed, name) {
executed = append(executed, name)
}
}
default:
runtime.Gosched()
Expand Down

0 comments on commit ce02759

Please sign in to comment.