Skip to content

Trailing whitespace with forced line breaks is not handled correctly #263

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

Open
wfdewith opened this issue Jan 31, 2025 · 0 comments · May be fixed by #276
Open

Trailing whitespace with forced line breaks is not handled correctly #263

wfdewith opened this issue Jan 31, 2025 · 0 comments · May be fixed by #276

Comments

@wfdewith
Copy link
Contributor

After #251, I noticed that trailing whitespace still shows up at the end of lines that end on a forced line break.

#[test]
fn trailing_whitespace() {
    let mut env = testenv!();

    let text = "AAA   \nBBB";
    let mut builder = env.builder(text);
    let mut layout = builder.build(text);
    layout.break_all_lines(None);
    layout.align(None, Alignment::Start, false);
    env.check_layout_snapshot(&layout);
}

With my patch that shows the padding, this renders the following image.

Image

Patch

diff --git a/parley/src/tests/utils/renderer.rs b/parley/src/tests/utils/renderer.rs
index 2169eb7..a5d6736 100644
--- a/parley/src/tests/utils/renderer.rs
+++ b/parley/src/tests/utils/renderer.rs
@@ -61,6 +61,15 @@ pub(crate) fn render_layout(
 
     let mut pen = TinySkiaPen::new(img.as_mut());
 
+    draw_rect(
+        &mut pen,
+        fpadding,
+        fpadding,
+        width as f32,
+        height as f32,
+        Color::from_rgba8(220, 220, 220, 255),
+    );
+
     for rect in selection_rects {
         draw_rect(
             &mut pen,

@wfdewith wfdewith added the bug Something isn't working label Jan 31, 2025
@xorgy xorgy removed the bug Something isn't working label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants