Skip to content

[BUG] One trailing newline ignored by rich.print in some cases #178

Closed
@mportesdev

Description

Hi, thanks for this great library.

Not sure if this is expected behavior or a bug. In certain cases, rich.print handles newlines in a slightly different manner than the print built-in.

Example:

>>> for i in range(3): print('Hey' + '\n' * i)
... 
Hey
Hey

Hey


>>> from rich import print
>>> for i in range(3): print('Hey' + '\n' * i)
... 
Hey
Hey
Hey

>>> 

Apparently, when the printed string contains at least one trailing newline (i.e. when i == 1 or i == 2), one newline is ignored by rich.print.

A screenshot of a similar example:
rich

(rich 3.3.2, Python 3.8.0, GNOME Terminal 3.18.3 on Linux Mint 18.2 64-bit)

Metadata

Assignees

No one assigned

    Labels

    acceptedTask was acceptedbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions