From f86f709c3e1e805a2ce7fabc2109152b88f1a7a8 Mon Sep 17 00:00:00 2001 From: mtlcl410 Date: Mon, 9 Nov 2026 10:29:15 +0800 Subject: [PATCH] M3: merge main's soft hyphen, zero width and CJK line-join search with the ligature and line-end hyphen readings (#4469) Main's #6595 made a soft hyphen invisible and a line ending in one run on, so the line-end hyphen readings now cover HYPHEN-MINUS and HYPHEN only, pass over invisible characters, and keep main's zero width space word boundaries in each reading. The reference oracle combines both. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA --- crates/render/src/text/search.rs | 9 ++++++++- crates/render/tests/it/search.rs | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/render/src/text/search.rs b/crates/render/src/text/search.rs index 54b02027e3..a52cf5251c 100644 --- a/crates/render/src/text/search.rs +++ b/crates/render/src/text/search.rs @@ -199,7 +199,14 @@ fn characters(page: &PageText, texts: &[String], divided: &[bool], reading: Hyph /// Non-overlapping hits of `needle` (with its KMP `prefix` table) in `chars`, as glyph ranges. /// `zero_width_space` says which characters come right after a skipped zero width space. -fn search(chars: &[(char, usize)], zero_width_space: &[bool], needle: &[char], prefix: &[usize], whole_words: bool, limit: usize) -> Vec> { +fn search( + chars: &[(char, usize)], + zero_width_space: &[bool], + needle: &[char], + prefix: &[usize], + whole_words: bool, + limit: usize, +) -> Vec> { if needle.len() > chars.len() { return Vec::new(); } diff --git a/crates/render/tests/it/search.rs b/crates/render/tests/it/search.rs index f1eeb0b8ed..0029d88b72 100644 --- a/crates/render/tests/it/search.rs +++ b/crates/render/tests/it/search.rs @@ -202,8 +202,9 @@ fn whole_word_rejection_keeps_overlapping_candidates() { #[test] fn search_matches_reference_for_unicode_gaps_limits_and_word_boundaries() { - let alphabet = - ["a", "b", " ", "-", "İ", "ı", "ς", "Σ", "\t", "\n", "ffi", "", "界", "e\u{301}", "العربية", "\u{FB01}", "b\u{AD}", "1", "\u{AD}", "a\u{200B}", "\u{2010}"]; + let alphabet = ["a", "b", " ", "-", "İ", "ı", "ς", "Σ", "\t", "\n", "ffi", "", "界", "e\u{301}", "العربية", "\u{AD}", "a\u{200B}"]; + // Ligatures, digits and HYPHEN exercise the readings of a line-end hyphen. + let alphabet: Vec<&str> = alphabet.into_iter().chain(["\u{FB01}", "1", "\u{2010}"]).collect(); let mut seed = 1234567u64; let mut next = || { seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1);