From dd5ea26cc72f3c39e9f8b4d8452a42c9c2f85442 Mon Sep 17 00:00:00 2001 From: Bartosz Zbytniewski <50180524+devzbysiu@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:40:03 +0100 Subject: feat: add moving tab to other position (#3047) * feat: add moving tab to other position * docs(changelog): revert changes * test: update config snapshots * refactor: get rid of HorizontalDirection enum * refactor: cleanup code order * refactor: use debug! instead of info! * refactor: use more defensive way to switch tabs * refactor: revert tip changes * refactor: code formatting * refactor: improve invalid input notification * refactor: inline fns for calculating target index --------- Co-authored-by: Jae-Heon Ji --- zellij-utils/src/kdl/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'zellij-utils/src/kdl/mod.rs') diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index 36d05aff0..1d7210907 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -453,6 +453,24 @@ impl Action { })?; Ok(Action::MoveFocusOrTab(direction)) }, + "MoveTab" => { + let direction = Direction::from_str(string.as_str()).map_err(|_| { + ConfigError::new_kdl_error( + format!("Invalid direction: '{}'", string), + action_node.span().offset(), + action_node.span().len(), + ) + })?; + if direction.is_vertical() { + Err(ConfigError::new_kdl_error( + format!("Invalid horizontal direction: '{}'", string), + action_node.span().offset(), + action_node.span().len(), + )) + } else { + Ok(Action::MoveTab(direction)) + } + }, "MovePane" => { if string.is_empty() { return Ok(Action::MovePane(None)); @@ -738,6 +756,11 @@ impl TryFrom<(&KdlNode, &Options)> for Action { action_arguments, kdl_action ), + "MoveTab" => parse_kdl_action_char_or_string_arguments!( + action_name, + action_arguments, + kdl_action + ), "MoveFocusOrTab" => parse_kdl_action_char_or_string_arguments!( action_name, action_arguments, -- cgit v1.2.3