diff --git a/src/config/segment.go b/src/config/segment.go index 7f92c8dc..64b93d4b 100644 --- a/src/config/segment.go +++ b/src/config/segment.go @@ -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() } diff --git a/src/prompt/segments.go b/src/prompt/segments.go index a959fd56..5d01912e 100644 --- a/src/prompt/segments.go +++ b/src/prompt/segments.go @@ -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()