diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-08-01 20:25:33 +0200 |
|---|---|---|
| committer | a-kenji <aks.kenji@protonmail.com> | 2021-08-01 20:25:33 +0200 |
| commit | fc7bc3cc8b8b6e6c652e85bb47424338e7038cbe (patch) | |
| tree | eb43e2b04ebe0c26e286bab77d842304ddae596d /zellij-utils/src/input | |
| parent | fixup! fix e2e fixtures (diff) | |
| parent | docs(changelog): Fix update plugins #621 (diff) | |
| download | sl0ppij-fc7bc3cc8b8b6e6c652e85bb47424338e7038cbe.tar.gz sl0ppij-fc7bc3cc8b8b6e6c652e85bb47424338e7038cbe.tar.xz sl0ppij-fc7bc3cc8b8b6e6c652e85bb47424338e7038cbe.zip | |
Merge branch 'main' of https://github.com/zellij-org/zellij into tab-layout
Diffstat (limited to 'zellij-utils/src/input')
| -rw-r--r-- | zellij-utils/src/input/actions.rs | 2 | ||||
| -rw-r--r-- | zellij-utils/src/input/layout.rs | 22 | ||||
| -rw-r--r-- | zellij-utils/src/input/unit/layout_test.rs | 5 |
3 files changed, 8 insertions, 21 deletions
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index ab711c75..dbced56d 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -49,6 +49,8 @@ pub enum Action { ScrollDown, /// Scroll down at point ScrollDownAt(Position), + /// Scroll down to bottom in focus pane. + ScrollToBottom, /// Scroll up one page in focus pane. PageScrollUp, /// Scroll down one page in focus pane. diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 26d96764..887350fb 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -123,8 +123,8 @@ impl Layout { layout: Option<&PathBuf>, layout_path: Option<&PathBuf>, layout_dir: Option<PathBuf>, - ) -> Option<Layout> { - let layout_result = layout + ) -> Option<Result<Layout, ConfigError>> { + layout .map(|p| Layout::from_dir(p, layout_dir.as_ref())) .or_else(|| layout_path.map(|p| Layout::new(p))) .or_else(|| { @@ -132,16 +132,7 @@ impl Layout { &std::path::PathBuf::from("default"), layout_dir.as_ref(), )) - }); - - match layout_result { - None => None, - Some(Ok(layout)) => Some(layout), - Some(Err(e)) => { - eprintln!("There was an error in the layout file:\n{}", e); - std::process::exit(1); - } - } + }) } // Currently still needed but on nightly @@ -297,12 +288,9 @@ impl Layout { pub fn construct_main_layout(&self) -> MainLayout { let (pre_tab, post_tab, tabs) = self.split_main_and_tab_layout(); + // Todo: A proper LayoutError if tabs.is_empty() { - panic!("The layout file should have a `tabs` section specified"); - } - - if tabs.len() > 1 { - panic!("The layout file should have one single tab in the `tabs` section specified"); + panic!("The layout file should have a [`tabs`] section specified"); } MainLayout { diff --git a/zellij-utils/src/input/unit/layout_test.rs b/zellij-utils/src/input/unit/layout_test.rs index 89217e04..5d9fda35 100644 --- a/zellij-utils/src/input/unit/layout_test.rs +++ b/zellij-utils/src/input/unit/layout_test.rs @@ -528,10 +528,7 @@ fn no_tabs_specified_should_panic() { } #[test] -#[should_panic] -// TODO Make error out of this -// Only untill #631 is fixed -fn multiple_tabs_specified_should_panic() { +fn multiple_tabs_specified_should_not_panic() { let path = layout_test_dir("multiple-tabs-should-panic.yaml".into()); let layout = Layout::new(&path); let _main_layout = layout.unwrap().construct_main_layout(); |
