From 5d1db4992a59c3de4f0a3fe2f9803c4a8de0fe0d Mon Sep 17 00:00:00 2001 From: Adam Kowalski Date: Thu, 8 Jan 2026 21:44:45 -0800 Subject: [PATCH] chore: extend fix to != and ++ ligatures, match existing test style --- src/shape.rs | 11 ++++++++--- tests/shaping_and_rendering.rs | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/shape.rs b/src/shape.rs index 19d0e31..71c6d35 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -829,11 +829,16 @@ impl ShapeSpan { // The unicode-linebreak crate treats the pipe character '|' as a break opportunity (BA/AL class). // This causes ShapeSpan::build to split text like '|>' into separate ShapeWords. // When these words are shaped independently, the font shaping engine cannot form ligatures that cross the word boundary. - // We manually check for the '|>' sequence during segmentation and skip the break opportunity to ensure they remain in the same shaping run. + // We manually check for known ligature sequences during segmentation and skip the break opportunity + // to ensure they remain in the same shaping run. if end_lb > 0 && end_lb < span.len() { let b = span.as_bytes(); - if b[end_lb - 1] == b'|' && b[end_lb] == b'>' { - continue; + match (b[end_lb - 1], b[end_lb]) { + (b'|', b'>') | // |> + (b'!', b'=') | // != + (b'+', b'+') // ++ + => continue, + _ => {} } } diff --git a/tests/shaping_and_rendering.rs b/tests/shaping_and_rendering.rs index 1841111..746aaf9 100644 --- a/tests/shaping_and_rendering.rs +++ b/tests/shaping_and_rendering.rs @@ -102,4 +102,28 @@ fn test_ligature_segmentation() { "Expected '|>' to be a single word (preserved for ligature), but found {} words.", span.words.len() ); + + // Test != + buffer.set_text("!=", &Attrs::new(), Shaping::Advanced, None); + buffer.shape_until_scroll(false); + let line = &buffer.lines[0]; + let shape = line.shape_opt().expect("ShapeLine not found"); + assert_eq!( + shape.spans[0].words.len(), + 1, + "Expected '!=' to be a single word, but found {} words.", + shape.spans[0].words.len() + ); + + // Test ++ + buffer.set_text("++", &Attrs::new(), Shaping::Advanced, None); + buffer.shape_until_scroll(false); + let line = &buffer.lines[0]; + let shape = line.shape_opt().expect("ShapeLine not found"); + assert_eq!( + shape.spans[0].words.len(), + 1, + "Expected '++' to be a single word, but found {} words.", + shape.spans[0].words.len() + ); } \ No newline at end of file