Merge pull request #224 from peterablehmann/main

Fix describe_node_list remaining nodes special case
This commit is contained in:
Zhaofeng Li 2024-10-06 19:14:38 -06:00 committed by GitHub
commit b0a62f234f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -874,11 +874,17 @@ fn describe_node_list(nodes: &[NodeName]) -> Option<String> {
} }
let (idx, next) = next.unwrap(); let (idx, next) = next.unwrap();
let remaining = rough_limit - s.len(); let remaining_text = rough_limit - s.len();
let remaining_nodes = total - idx;
if next.len() + other_text.len() >= remaining { if next.len() + other_text.len() >= remaining_text {
write!(s, ", and {} other nodes", total - idx).unwrap(); if remaining_nodes == 1 {
write!(s, ", and {}", next.as_str()).unwrap();
break; break;
} else {
write!(s, ", and {} other nodes", remaining_nodes).unwrap();
break;
}
} }
} }