From d70fb24eb12fcc1812d6a0640c575dccb1a75b48 Mon Sep 17 00:00:00 2001 From: jude Date: Fri, 6 Jan 2023 17:08:09 +0000 Subject: [PATCH] Fix todo viewing not working for large entries Was not checking the length of the item when trying to add it to the dropdown, causing failures. --- src/commands/todo_cmds.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commands/todo_cmds.rs b/src/commands/todo_cmds.rs index 90be423..f1a1f88 100644 --- a/src/commands/todo_cmds.rs +++ b/src/commands/todo_cmds.rs @@ -340,7 +340,18 @@ pub fn show_todo_page( opt.create_option(|o| { o.label(format!("Mark {} complete", count + first_num)) .value(id) - .description(disp.split_once(' ').unwrap_or(("", "")).1) + .description({ + let c = disp.split_once(' ').unwrap_or(("", "")).1; + + if c.len() > 100 { + format!( + "{}...", + c.chars().take(97).collect::() + ) + } else { + c.to_string() + } + }) }); }