Skip to content

Commit

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

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

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

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

segment.SetText(text)
segment.env.TemplateCache().AddSegmentData(segment.Name(), segment.writer)
segment.writer.SetText(text)
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,6 +59,11 @@ 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 @@ -75,11 +80,6 @@ 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 f838eaf

Please sign in to comment.