Skip to content

Background style is not rendered when wrapping other rendered styles #209

Open
@drakenstar

Description

@drakenstar

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.

Screen Shot 2023-07-26 at 12 07 59 am

Setup

  • macOS 11.5.2
  • zsh and bash
  • iTerm2 and Terminal.app
  • Locale: en_US.UTF-8

Source Code
Simple reproduce:

	redStyle := lipgloss.NewStyle().
		Background(lipgloss.Color("#FF0000")).
		Width(10)

	greenStyle := lipgloss.NewStyle().
		Background(lipgloss.Color("#00FF00")).
		Width(10)

	outerStyle := lipgloss.NewStyle().
		Width(40).
		Background(lipgloss.Color("#0000FF"))

	fmt.Print(outerStyle.Render(lipgloss.JoinHorizontal(0,
		greenStyle.Render("left text"),
		redStyle.Render("multi\nline\ncenter\ntext"),
		greenStyle.Render("right text"),
	)))

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions