Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Fix panic wrapping multibyte char at width boundary

+19 -2
+8
CHANGELOG.md
··· 5 5 6 6 # Changelog 7 7 8 + ## Unreleased 9 + 10 + ### Bug fixes 11 + 12 + - Fixed a bug where the compiler would crash when wrapping an error message 13 + whose line broke in the middle of a multi-byte UTF-8 character. 14 + ([John Downey](https://github.com/jtdowney)) 15 + 8 16 ## v1.18.0-rc1 - 2026-07-21 9 17 10 18 ### Compiler
+4 -2
compiler-core/src/error.rs
··· 5307 5307 // breaks word into n lines based on width. Returns list of new lines and remainder 5308 5308 fn break_word(word: &str, width: usize) -> (Vec<Cow<'_, str>>, &str) { 5309 5309 let mut new_lines: Vec<Cow<'_, str>> = Vec::new(); 5310 - let (first, mut remainder) = word.split_at(width); 5310 + // split on a char boundary so a multi-byte UTF-8 char straddling `width` 5311 + // can't panic. 5312 + let (first, mut remainder) = word.split_at(word.floor_char_boundary(width)); 5311 5313 new_lines.push(Cow::from(first)); 5312 5314 5313 5315 // split remainder until it's small enough 5314 5316 while remainder.len() > width { 5315 - let (first, second) = remainder.split_at(width); 5317 + let (first, second) = remainder.split_at(remainder.floor_char_boundary(width)); 5316 5318 new_lines.push(Cow::from(first)); 5317 5319 remainder = second; 5318 5320 }
+7
compiler-core/src/error/tests.rs
··· 215 215 .pretty_string(); 216 216 assert_snapshot!(error); 217 217 } 218 + 219 + #[test] 220 + fn wrap_with_multibyte_char_at_width_boundary() { 221 + let input = format!("{}é", "a".repeat(74)); 222 + let wrapped = wrap(&input); 223 + assert_eq!(wrapped.replace('\n', ""), input); 224 + }