diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index 7299d51..c43e597 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -577,13 +577,15 @@ fn newest_section(heading: &str, lines: &[String], cap: usize) -> String { if !out.push(heading) { return String::new(); } + let mut shown = false; if dropped > 0 { - out.push(&format!("({dropped} earlier not shown)")); + shown |= out.push(&format!("({dropped} earlier not shown)")); } for line in kept { - out.push(line); + shown |= out.push(line); } - out.out + // A heading over nothing says nothing. + if shown { out.out } else { String::new() } } /// The messages to her as lines under the `addressed_bytes` ceiling: whole messages, newest first, until the ceiling; diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 5af0c2c..4941a25 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -1056,6 +1056,7 @@ fn a_beat_respects_a_small_cap() { let room = Room { tail: (0..6).map(|at| message("#swarm:gamecult.org", "@kiko:gamecult.org", "", &"x".repeat(150), 30 - at, false)).collect(), ..Room::default() }; let packet = packet_tuned(TurnKind::Beat, &state(), &room, &History::default(), 1, &tuning); assert!(packet.stimulus.len() <= cap, "cap {cap}: {} {:?}", packet.stimulus.len(), packet.stimulus); + assert!(!packet.stimulus.trim_end().ends_with("Lately in her rooms:"), "cap {cap}: no heading over nothing: {:?}", packet.stimulus); } }