aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-14 18:16:13 +0300
committerGitHub <noreply@github.com>2026-09-14 18:16:13 +0300
commit03749ae3970a74e077fc16b9327bddfc957771c9 (patch)
tree1818341b728ad85d2ffd549b1e5a2956dff6dd8e
parent0af53b75d9220c6d528b80104f0231fe447e93b2 (diff)
fix: default pane splits to the calling pane (#4123)
-rw-r--r--docs/next/website/src/content/docs/cli-reference.mdx5
-rw-r--r--src/cli/pane.rs33
2 files changed, 25 insertions, 13 deletions
diff --git a/docs/next/website/src/content/docs/cli-reference.mdx b/docs/next/website/src/content/docs/cli-reference.mdx
index 9d736c39..9f61d02d 100644
--- a/docs/next/website/src/content/docs/cli-reference.mdx
+++ b/docs/next/website/src/content/docs/cli-reference.mdx
@@ -225,8 +225,9 @@ herdr pane close <pane_id>
For pane commands that accept `--current`, Herdr uses the calling pane's
`HERDR_PANE_ID` when the command runs inside a Herdr pane. For `pane split`,
-an explicit pane id or `--pane ID` splits that pane, `--current` splits the
-calling pane, and an omitted target keeps using the UI-focused pane.
+an explicit pane id or `--pane ID` splits that pane. An omitted target splits
+the calling pane when `HERDR_PANE_ID` is available, otherwise the focused pane.
+`--current` requires a calling pane and errors when `HERDR_PANE_ID` is unavailable.
The split response exposes the new pane ID as `.result.pane.pane_id`.
`pane input --right-click pane` forwards unmodified right-click gestures to a
diff --git a/src/cli/pane.rs b/src/cli/pane.rs
index 896cee45..3b900e17 100644
--- a/src/cli/pane.rs
+++ b/src/cli/pane.rs
@@ -633,7 +633,7 @@ fn parse_pane_split_args(
) -> Result<PaneSplitParams, String> {
let args = super::expand_equals_args(args, &["--right-click"]);
let mut env = std::collections::HashMap::new();
- let mut pane_id = None;
+ let mut pane_id = env_pane_id.map(super::normalize_pane_id);
let mut direction = None;
let mut ratio = None;
let mut cwd = None;
@@ -1783,22 +1783,33 @@ mod tests {
}
#[test]
- fn parse_pane_split_args_omitted_target_keeps_focused_fallback() {
- let params =
- parse_pane_split_args(&args(&["--direction", "down"]), Some("issue-1")).unwrap();
+ fn parse_pane_split_args_omitted_target_uses_caller() {
+ let params = parse_pane_split_args(
+ &args(&["--no-focus", "--direction", "right", "--cwd", "/var/tmp"]),
+ Some("w1:p2"),
+ )
+ .unwrap();
+
+ assert_eq!(params.target_pane_id, Some("w1:p2".into()));
+ assert!(!params.focus);
+ }
+
+ #[test]
+ fn parse_pane_split_args_without_caller_keeps_focused_fallback() {
+ let params = parse_pane_split_args(&args(&["--direction", "down"]), None).unwrap();
assert_eq!(params.target_pane_id, None);
- assert_eq!(params.direction, crate::api::schema::SplitDirection::Down);
}
#[test]
- fn parse_pane_split_args_accepts_pane_option() {
- let params =
- parse_pane_split_args(&args(&["--pane", "issue-2", "--direction", "right"]), None)
- .unwrap();
+ fn parse_pane_split_args_explicit_target_overrides_caller() {
+ for target in [args(&["w2:p3"]), args(&["--pane", "w2:p3"])] {
+ let mut input = target;
+ input.extend(args(&["--direction", "right"]));
+ let params = parse_pane_split_args(&input, Some("w1:p2")).unwrap();
- assert_eq!(params.target_pane_id, Some("issue-2".into()));
- assert_eq!(params.direction, crate::api::schema::SplitDirection::Right);
+ assert_eq!(params.target_pane_id, Some("w2:p3".into()));
+ }
}
#[test]