diff --git a/crates/mind-body/src/projection/read.rs b/crates/mind-body/src/projection/read.rs index 26fe9ae..e94b215 100644 --- a/crates/mind-body/src/projection/read.rs +++ b/crates/mind-body/src/projection/read.rs @@ -475,7 +475,7 @@ fn fixture_search(entries: &[ReadEntry], request: &ReadRequest) -> Option>().join("\n")) + Ok(format!("{}\n{TITLES_ONLY}", items.iter().map(|item| format!("- {}", facts_words(&item.facts))).collect::>().join("\n"))) } fn rulings(&self, slug: &str, since: DateTime) -> Result { @@ -547,11 +547,20 @@ impl LiveReads { } } +/// The line that ends a read whose result is titles and nothing of what they head (map 16.35, R19): she reads it with the +/// list, so she does not describe the contents of what she only saw named. +pub(crate) const TITLES_ONLY: &str = "Only titles were returned here; the contents were not read."; + /// What a campaign read shows, live and in the simulator alike (map 16.25.8): each ruling, newest first, at most /// `RULINGS_SHOWN`, as `- {title}: {ruling}`, or `- {title}` when no ruling text is held. None is not found. pub(crate) fn rulings_text<'a>(rulings: impl IntoIterator)>) -> Result { - let shown: Vec = rulings.into_iter().take(RULINGS_SHOWN as usize).map(|(title, ruling)| ruling.map_or_else(|| format!("- {title}"), |ruling| format!("- {title}: {ruling}"))).collect(); - if shown.is_empty() { Err(ReadFailure::NotFound) } else { Ok(shown.join("\n")) } + let rulings: Vec<(&str, Option<&str>)> = rulings.into_iter().take(RULINGS_SHOWN as usize).collect(); + let shown: Vec = rulings.iter().map(|(title, ruling)| ruling.map_or_else(|| format!("- {title}"), |ruling| format!("- {title}: {ruling}"))).collect(); + if shown.is_empty() { + return Err(ReadFailure::NotFound); + } + let titled = rulings.iter().any(|(_, ruling)| ruling.is_none()); + Ok(if titled { format!("{}\n{TITLES_ONLY}", shown.join("\n")) } else { shown.join("\n") }) } fn forge_text(forge: &dyn ForgeGet, path: &str) -> Result { @@ -596,7 +605,8 @@ fn repo_read(forge: &dyn ForgeGet, target: &str) -> Result Ok(format!("{} Recent pull requests, merged and closed: -{}", repo["description"].as_str().unwrap_or_default(), listed.join(" +{} +{TITLES_ONLY}", repo["description"].as_str().unwrap_or_default(), listed.join(" "))) } Some('#') => { @@ -632,7 +642,7 @@ fn search(forge: &dyn ForgeGet, name: &str, words: &str) -> Result