mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-22 00:21:11 -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.setEnabledSegments()
|
||||||
b.setSegmentsText()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) setEnabledSegments() {
|
func (b *Block) setEnabledSegments() {
|
||||||
|
@ -94,15 +93,3 @@ func (b *Block) setEnabledSegments() {
|
||||||
}(segment)
|
}(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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ type Segment struct {
|
||||||
CacheDuration cache.Duration `json:"cache_duration,omitempty" toml:"cache_duration,omitempty"`
|
CacheDuration cache.Duration `json:"cache_duration,omitempty" toml:"cache_duration,omitempty"`
|
||||||
|
|
||||||
Enabled bool `json:"-" toml:"-"`
|
Enabled bool `json:"-" toml:"-"`
|
||||||
|
|
||||||
Text string `json:"-" toml:"-"`
|
Text string `json:"-" toml:"-"`
|
||||||
|
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
@ -205,8 +204,8 @@ func (segment *Segment) writerCacheKey() string {
|
||||||
return fmt.Sprintf("segment_cache_writer_%s_%s", segment.Name(), segment.env.Pwd())
|
return fmt.Sprintf("segment_cache_writer_%s_%s", segment.Name(), segment.env.Pwd())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (segment *Segment) setText() {
|
func (segment *Segment) SetText() {
|
||||||
if !segment.Enabled || len(segment.Text) != 0 {
|
if !segment.Enabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,8 @@ func (e *Engine) filterSegments(block *config.Block) {
|
||||||
segments := make([]*config.Segment, 0)
|
segments := make([]*config.Segment, 0)
|
||||||
|
|
||||||
for _, segment := range block.Segments {
|
for _, segment := range block.Segments {
|
||||||
|
segment.SetText()
|
||||||
|
|
||||||
if !segment.Enabled && segment.ResolveStyle() != config.Accordion {
|
if !segment.Enabled && segment.ResolveStyle() != config.Accordion {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue