From ddeefdbddeaff0dfb7dfead05098c9befd2eec06 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:02:34 -0400 Subject: [PATCH] fix: stats log name limit --- server/algorithms/src/stats.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/algorithms/src/stats.rs b/server/algorithms/src/stats.rs index 52ac03e1..557f6afc 100644 --- a/server/algorithms/src/stats.rs +++ b/server/algorithms/src/stats.rs @@ -60,10 +60,16 @@ impl Stats { pub fn log(&self, area: Option) { let get_row = |text: String, replace: bool| { + let safe_text: String = if text.len() > WIDTH.len() - 4 { + text[..(WIDTH.len() - 4)].to_string() + } else { + text + }; format!( " {}{}{}\n", - text, - WIDTH[..(WIDTH.len() - text.len())].replace("=", if replace { " " } else { "=" }), + safe_text, + WIDTH[..(WIDTH.len() - safe_text.len())] + .replace("=", if replace { " " } else { "=" }), if replace { "||" } else { "==" } ) };