mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
feat(block): allow force rendering
This commit is contained in:
parent
829d526376
commit
e16898fc7c
|
@ -36,4 +36,5 @@ type Block struct {
|
||||||
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
||||||
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
||||||
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
||||||
|
Force bool `json:"force,omitempty" toml:"force,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,8 +196,8 @@ func (e *Engine) getTitleTemplateText() string {
|
||||||
func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool {
|
func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool {
|
||||||
text, length := e.writeBlockSegments(block)
|
text, length := e.writeBlockSegments(block)
|
||||||
|
|
||||||
// do not print anything when we don't have any text
|
// do not print anything when we don't have any text unless forced
|
||||||
if length == 0 {
|
if !block.Force && length == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import Config from "@site/src/components/Config.js";
|
||||||
| `leading_diamond` | `string` |
|
| `leading_diamond` | `string` |
|
||||||
| `trailing_diamond` | `string` |
|
| `trailing_diamond` | `string` |
|
||||||
| `segments` | `array` |
|
| `segments` | `array` |
|
||||||
|
| `force` | `boolean` |
|
||||||
|
|
||||||
### Type
|
### 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].
|
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
|
[color-overrides]: /docs/configuration/colors#color-overrides
|
||||||
[segment]: segment.mdx
|
[segment]: segment.mdx
|
||||||
|
|
Loading…
Reference in a new issue