feat(block): allow force rendering

resolves #6002
This commit is contained in:
Jan De Dobbeleer 2024-12-12 13:32:52 +01:00 committed by Jan De Dobbeleer
parent b0ecd21ce7
commit 57f18f8ed2
3 changed files with 8 additions and 2 deletions

View file

@ -36,4 +36,5 @@ type Block struct {
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
Force bool `json:"force,omitempty" toml:"force,omitempty"`
}

View file

@ -196,8 +196,8 @@ func (e *Engine) getTitleTemplateText() string {
func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool {
text, length := e.writeBlockSegments(block)
// do not print anything when we don't have any text
if length == 0 {
// do not print anything when we don't have any text unless forced
if !block.Force && length == 0 {
return false
}

View file

@ -32,6 +32,7 @@ import Config from "@site/src/components/Config.js";
| `leading_diamond` | `string` |
| `trailing_diamond` | `string` |
| `segments` | `array` |
| `force` | `boolean` |
### Type
@ -114,5 +115,9 @@ with the same trailing diamond, regardless of which segment is enabled or not.
Array of one or more [segments][segment].
### Force
When set to `true`, the block will always be rendered, even if all segments are empty. Defaults to `false`.
[color-overrides]: /docs/configuration/colors#color-overrides
[segment]: segment.mdx