From e62bb93df3a5d8f910491bfed8aea2463d5a0dec Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 20 Oct 2022 20:16:46 +0200 Subject: fix(layouts): various bugs and better errors (#1831) * fix(layout): error on percent size 0 * fix(command): better error on invalid commands * fix(layouts): better error on unknown pane nodes * fix(layouts): disallow certain template names * style(fmt): rustfmt --- zellij-utils/src/input/layout.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'zellij-utils/src/input/layout.rs') diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index b041412e2..e283b4455 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -575,7 +575,11 @@ impl FromStr for SplitSize { if s.chars().last() == Some('%') { let char_count = s.chars().count(); let percent_size = usize::from_str_radix(&s[..char_count.saturating_sub(1)], 10)?; - Ok(SplitSize::Percent(percent_size)) + if percent_size > 0 && percent_size <= 100 { + Ok(SplitSize::Percent(percent_size)) + } else { + Err("Percent must be between 0 and 100".into()) + } } else { let fixed_size = usize::from_str_radix(s, 10)?; Ok(SplitSize::Fixed(fixed_size)) -- cgit v1.2.3