Skip to content

style.Render() adds excess whitespaces on every line of the supplied text #577

@TLINDEN

Description

@TLINDEN

Describe the bug
I am using bubbles/viewport which shows text colored using lipgloss. Basically I colorize the text like this:

buf.WriteString(conf.Colors.Body.Render(content.Body))

buf is a strings.Builder, which I later put as content into the viewport widget.

The Problem is, that this appends excess whitespaces to every line except empty lines. Sample output:

Fabio Rossi ließ sie wieder auf die Bettdecke sinken und versuchte, dorthin zurückzukehren, wo er sich eben noch befunden hatte. An den Ort ohne Gefühle, Geräusche, Gedanken und Gerüche.                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Hower, when I change the code to this:

buf.WriteString(content.Body)

no excess whitespaces appear.

What's interesting is that it looks as expected inside the viewport widget, so it seems to be intended. However, if I just print it to STDOUT, I can see the excess spaces.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS Ubuntu 25.04
  • Shell bash
  • Terminal xfce-terminal
  • Terminal Multiplexer tmux
  • Locale en_US.UTF-8

To Reproduce
Steps to reproduce the behavior:
Snippet see above, feed in a large block of text, which contains lines wider than the terminal width. It doesn't happen, when all lines are smaller than the terminal.

Source Code

Expected behavior
Do not append any excess spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions