-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background style is not rendered when wrapping other rendered styles #209
Comments
Ok I dug into this and I think found the reason for this output. s := wordwrap.String("test test ", 6)
fmt.Print(s)
// "test\ntest"
s := wordwrap.String("test \ntest ", 6)
fmt.Print(s)
// "test \ntest" This is arguably surprising from their end, however lipgloss could workaround this by trimming whitespace this output if it is not styled by seeking backwards per line for I'm happy to PR this if there's agreement it should be fixed. |
For now, I'd probably workaround this by simply placing the short column (or all columns) over the appropriate background color with Here’s how I'd fix my above example (in a real scenario I'd abstract the package main
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
func main() {
const blue = lipgloss.Color("#0000FF")
redStyle := lipgloss.NewStyle().
Background(lipgloss.Color("#FF0000")).
Width(10)
greenStyle := lipgloss.NewStyle().
Background(lipgloss.Color("#00FF00")).
Width(10)
outerStyle := lipgloss.NewStyle().
Width(40).
Background(blue)
leftContent := greenStyle.Render("left text")
middleContent := redStyle.Render("multi\nline\ncenter\ntext\nwow")
rightContent := greenStyle.Render("right text")
fmt.Println(outerStyle.Render(
lipgloss.JoinHorizontal(
lipgloss.Center,
leftContent,
middleContent,
lipgloss.Place(
lipgloss.Width(rightContent), // width
lipgloss.Height(middleContent), // height
lipgloss.Left, // x
lipgloss.Center, // y
rightContent, // content
lipgloss.WithWhitespaceBackground(blue), // background
),
)))
} Output: |
Describe the bug
When rendering strings with backgrounds already applied, the background from our rendering style has issues. In this test case, I've joined 3 other strings using
JoinHorizontal
that each have their own background. Note the missing background beneath the "right text" section:Note the area beneath "right text" that does not have a background style applied.
Setup
Source Code
Simple reproduce:
Expected behavior
In this case I would have expected the blue background from
style3
to be rendered in all spaces where there is no background applied.The text was updated successfully, but these errors were encountered: