diff options
author | Aram Drevekenin <aram@poor.dev> | 2022-10-20 20:16:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 20:16:46 +0200 |
commit | e62bb93df3a5d8f910491bfed8aea2463d5a0dec (patch) | |
tree | 3cd3da58e3a5d3deab665c0e56797888429fcae7 /zellij-utils/src/input/layout.rs | |
parent | ebc4222d6af7734e346dcf00442422cadfe5cdf6 (diff) |
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
Diffstat (limited to 'zellij-utils/src/input/layout.rs')
-rw-r--r-- | zellij-utils/src/input/layout.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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)) |