fix: detached new-window/split-window inherit the caller's working directory (tmux parity) - #101
Closed
marhel wants to merge 3 commits into
Closed
fix: detached new-window/split-window inherit the caller's working directory (tmux parity)#101marhel wants to merge 3 commits into
marhel wants to merge 3 commits into
Conversation
A detached `new-window` invoked without an explicit `-c` inherited the session's original start directory instead of the working directory of the process that issued the command. tmux uses the caller's working directory here, so running `new-window` from a directory other than the one the session was created in diverged from tmux. Fall back to the caller's current working directory when no start directory is given, mirroring what `new-session` already does. Add a regression test that creates a session in one directory and runs a detached `new-window` from another, asserting the new pane inherits the caller's directory. Tested on Linux. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Martin Hellspong <martin.hellspong@factor10.com>
A detached `split-window` without an explicit `-c` inherited the session's original start directory instead of the caller's working directory, diverging from tmux (same bug already fixed for `new-window`). Apply the caller-cwd fallback in both the target-action and legacy split paths, extracting the shared `caller_current_working_directory` helper. Parametrize the caller-cwd regression test over both subcommands. Tested on Linux. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Martin Hellspong <martin.hellspong@factor10.com>
…reation Add a compatibility-matrix row noting that a detached `new-window` or `split-window` without an explicit `-c` inherits the caller's working directory rather than the session's start directory, matching tmux. Both paths are now fixed and covered by a parametrized regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Martin Hellspong <martin.hellspong@factor10.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #99
Summary
A detached
new-windoworsplit-windowinvoked without an explicit-cinherited the session's original start directory instead of the working
directory of the process that issued the command. tmux uses the caller's
working directory in this case, so running either command from a directory
other than the one the session was created in diverged from tmux.
Both commands are covered here so the issue can be closed as a whole.
Reproduction (Linux, isolated sockets)
new-window$C(caller)$S(session)$C✓split-window$C(caller)$S(session)$C✓Verified head-to-head against tmux 3.2a on Linux.
Cause
The CLI forwarded only an explicit
-cvalue and sentNoneotherwise, so theserver fell back to the session's cwd.
new-sessionalready falls back to thecaller's working directory in the same situation —
new-windowandsplit-windowsimply didn't.Fix
Fall back to the caller's current working directory when no start directory is
given, mirroring
new-session. The server already prefers an explicit startdirectory over the session cwd, so no server change is needed.
caller_current_working_directory()helper incrate::cli.new-window: applied the fallback inrun_new_window.split-window: applied it in both the target-action and legacy paths, and inthe request-variant routing condition (the plain
SplitWindowrequest cannotcarry a start directory, so a resolved cwd now routes through
SplitWindowExt).Tests
A single parametrized regression test (
tests/detached_caller_cwd.rs) runs thesame scenario for both subcommands: it creates a session in one directory and
runs the detached command from another, asserting the new pane inherits the
caller's directory. RED before the fix (for the command not yet fixed), GREEN
after.
Docs
Added a row to
docs/tmux-compat-decisions.mdrecording this asISO required(rmux must match tmux), backed by the regression test per the doc's CI policy.
Checks
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo build --workspace— cleancargo test --workspace --all-targets— all green except one pre-existing,environment-sensitive
rmux-serverlive-attach PTY test(
live_attach_large_bracketed_paste_survives_irregular_chunks,handler_send_keys_tests/input_capture.rs). This change touches zerormux-serverfiles, so that test binary is unaffected by it.Tested on Linux and Windows.