Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion failed when source text contains \r character #74

Closed
zombiepigdragon opened this issue Feb 17, 2023 · 0 comments · Fixed by #124
Closed

assertion failed when source text contains \r character #74

zombiepigdragon opened this issue Feb 17, 2023 · 0 comments · Fixed by #124

Comments

@zombiepigdragon
Copy link

MRE:

// cosmic-text = "0.7.0"
use cosmic_text::{Attrs, Buffer, FontSystem, Metrics};

fn main() {
    let font_system = FontSystem::new();
    let metrics = Metrics::new(14, 20);
    let mut buffer = Buffer::new(&font_system, metrics);
    buffer.set_size(80, 25);
    let attrs = Attrs::new();
    let message = "A\rB"; // Problem!
    buffer.set_text(message, attrs);
}

Discovered while trying to develop an X11 application- the Enter key sent a "\r" instead of a "\n", which my prototype application (not using Editor) simply appended to the end of the rendered buffer, causing a crash when the next character was appended.

The cause seems to be that \r is treated as a paragraph separator by unicode-bidi, but not by the lines iterator from std uses to do paragraph separator in buffer.set_text(), so when the paragraph is sent to be shaped it's split into two paragraphs and triggers the assert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant