From 569c914f9538c7267d2a39b1d8aae206ac4d95ce Mon Sep 17 00:00:00 2001 From: Peter Lehmann Date: Mon, 2 Sep 2024 22:32:59 +0200 Subject: [PATCH] Fix describe_node_list remaining nodes special case Colmena truncates left over node names when it reaches a certain char limit. This in it self is a sensible behaivior, but it should only do so if there is more then one node name remaining. --- src/job.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/job.rs b/src/job.rs index bfc003e..1b7616c 100644 --- a/src/job.rs +++ b/src/job.rs @@ -874,11 +874,17 @@ fn describe_node_list(nodes: &[NodeName]) -> Option { } 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 { - write!(s, ", and {} other nodes", total - idx).unwrap(); - break; + if next.len() + other_text.len() >= remaining_text { + if remaining_nodes == 1 { + write!(s, ", and {}", next.as_str()).unwrap(); + break; + } else { + write!(s, ", and {} other nodes", remaining_nodes).unwrap(); + break; + } } }