Skip to content

leading newline makes Text disappear #308

@ethanpailes

Description

@ethanpailes

Bug Description

When a string with a leading newline is passed to the Text widget, the text below that newline does not show up. It appears that this leading newline is not being included in some height computation because if there are multiple lines of text after a single leading newline, only the last line of text gets swallowed.

What did I Expect to Happen?

I would expect that leading newlines get included in the text that is displayed as well as all of the following text.

Minimal Example

use iced::{Element, Sandbox, Settings, Text};

pub fn main() {
    Bug::run(Settings::default())
}

struct Bug;

impl Sandbox for Bug {
    type Message = ();

    fn new() -> Bug {
        Bug
    }

    fn title(&self) -> String {
        String::from("A minimal repro")
    }

    fn update(&mut self, _message: Self::Message) {
    }

    fn view(&mut self) -> Element<Self::Message> {
        Text::new("\nmissing").into()
    }
}

Screenshot

Screen Shot 2020-04-19 at 1 58 27 PM

Multi-line Example

use iced::{Element, Sandbox, Settings, Text};

pub fn main() {
    Bug::run(Settings::default())
}

struct Bug;

impl Sandbox for Bug {
    type Message = ();

    fn new() -> Bug {
        Bug
    }

    fn title(&self) -> String {
        String::from("A minimal repro")
    }

    fn update(&mut self, _message: Self::Message) {
    }

    fn view(&mut self) -> Element<Self::Message> {
        Text::new("\nnow it shows up\nthis guy is missing though").into()
    }
}

Screenshot

Screen Shot 2020-04-19 at 2 05 31 PM

More details about my system

$ uname -a
Darwin ethanpailesmac 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtext

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions