fix: run :! and :term shell commands in the active pane's directory - #23
Merged
Conversation
Both `run_shell_capture` (:!) and `run_pending_shell_command` (:term) spawned `sh -c` without setting a working directory, so they inherited rodeo's own process cwd instead of the currently active pane's directory. Add `.current_dir()` to both call sites, plus regression tests covering the right-pane-active, left-pane-active, and mid-session-switch cases. Fixes #20
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.
Summary
Fixes #20.
Both
:!cmd(run_shell_captureinsrc/ui/input.rs) and:term cmd(run_pending_shell_commandinsrc/ui/mod.rs) spawnedsh -cwithout setting a working directory, so the child process inherited rodeo's own process cwd instead of the currently active pane's directory. This is broader than "always the left pane" — it's "always wherever rodeo was launched from" — which just happens to usually match the left pane's initial directory, matching the reported symptom.Changes
src/ui/input.rs:run_shell_capturenow captures the active pane's path up front and passes it via.current_dir()to the spawned shell.src/ui/mod.rs:run_pending_shell_commandgets the identical fix for:term.src/ui/input.rs: added 3 regression tests:shell_capture_runs_in_the_right_panes_directory_when_right_is_activeshell_capture_runs_in_the_left_panes_directory_by_defaultshell_capture_follows_active_pane_switches_mid_sessionEach redirects
pwd's stdout to a marker file (!pwd > '<path>') rather than relying on the in-app output-capture UI, and canonicalizes the tempdir paths before comparison to avoid flakiness from symlinked temp dirs (e.g. macOS/var→/private/var), matching the existing convention already used insrc/ui/git.rs.CHANGELOG.md: new# Unreleased/## Fixedentry.Scope notes
Command::newspawn sites for the same gap:src/ui/git.rsalready passes-C <dir>explicitly, andsrc/updater.rs's calls aren't pane-relative — no changes needed there.$EDITORlaunch (src/ui/mod.rs,run_pending_editor) has the same theoretical missing-.current_dir()gap, but it opens an absolute file path and isn't part of this issue's report, so it's deliberately left untouched — worth a separate follow-up if desired.run_pending_shell_command(:term) isn't covered by a direct automated test, since it requires a live terminal and blocks on stdin; the fix is a one-line change identical in shape to the tested:!path.Verification
cargo build— clean, no warningscargo test— 525 tests, all passing (506 unit + 7 file_ops + 1 man + 11 render)cargo clippy --all-targets -- -D warnings— cleancargo fmt --check— clean