mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-21 16:11:20 -08:00
refactor: render segment text in sequence
This commit is contained in:
parent
9e1942035f
commit
0853a527a7
|
@ -79,7 +79,6 @@ func (b *Block) executeSegmentLogic() {
|
|||
}
|
||||
|
||||
b.setEnabledSegments()
|
||||
b.setSegmentsText()
|
||||
}
|
||||
|
||||
func (b *Block) setEnabledSegments() {
|
||||
|
@ -94,15 +93,3 @@ func (b *Block) setEnabledSegments() {
|
|||
}(segment)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Block) setSegmentsText() {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(b.Segments))
|
||||
defer wg.Wait()
|
||||
for _, segment := range b.Segments {
|
||||
go func(s *Segment) {
|
||||
defer wg.Done()
|
||||
s.setText()
|
||||
}(segment)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,9 +59,8 @@ type Segment struct {
|
|||
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
||||
CacheDuration cache.Duration `json:"cache_duration,omitempty" toml:"cache_duration,omitempty"`
|
||||
|
||||
Enabled bool `json:"-" toml:"-"`
|
||||
|
||||
Text string `json:"-" toml:"-"`
|
||||
Enabled bool `json:"-" toml:"-"`
|
||||
Text string `json:"-" toml:"-"`
|
||||
|
||||
env runtime.Environment
|
||||
writer SegmentWriter
|
||||
|
@ -205,8 +204,8 @@ func (segment *Segment) writerCacheKey() string {
|
|||
return fmt.Sprintf("segment_cache_writer_%s_%s", segment.Name(), segment.env.Pwd())
|
||||
}
|
||||
|
||||
func (segment *Segment) setText() {
|
||||
if !segment.Enabled || len(segment.Text) != 0 {
|
||||
func (segment *Segment) SetText() {
|
||||
if !segment.Enabled {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -323,6 +323,8 @@ func (e *Engine) filterSegments(block *config.Block) {
|
|||
segments := make([]*config.Segment, 0)
|
||||
|
||||
for _, segment := range block.Segments {
|
||||
segment.SetText()
|
||||
|
||||
if !segment.Enabled && segment.ResolveStyle() != config.Accordion {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue