revert(segment): add to cache after rendering

This commit is contained in:
Jan De Dobbeleer 2024-11-08 16:02:02 +01:00 committed by Jan De Dobbeleer
parent 7f97c36adb
commit f838eaf00a
2 changed files with 11 additions and 9 deletions

View file

@ -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() {
@ -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()
}

View file

@ -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 {
@ -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()