Skip to content

Panic on multiline LayoutJob when segment has empty string #7378

@HactarCE

Description

@HactarCE

The following code panics in debug mode with the message Bad byte_range: 1..1:

let mut job = egui::text::LayoutJob::default();
job.append("\n", 0.0, egui::TextFormat::default());
job.append("", 0.0, egui::TextFormat::default());
ui.label(job);

The problem is in layout_each_paragraph_individually() with the "Section range overlaps with paragraph range" assert.

This can be fixed by changing the assert from section_range.start < section_range.end to section_range.start <= section_range.end, or by changing the else to else if section_range.start < section_range.end (to avoid doing zero-length slices anyway).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions