mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-22 22:26:54 +03:00
feat(panes): reuse CWD when dropping to shell in command panes (#2915)
This commit is contained in:
parent
83cf6d6e7c
commit
261c75ab92
@ -196,11 +196,13 @@ impl Pane for TerminalPane {
|
||||
Some(AdjustedInput::ReRunCommandInThisPane(run_command))
|
||||
},
|
||||
ESC => {
|
||||
// Drop to shell in the same working directory as the command was run
|
||||
let working_dir = run_command.cwd.clone();
|
||||
self.is_held = None;
|
||||
self.grid.reset_terminal_state();
|
||||
self.set_should_render(true);
|
||||
self.remove_banner();
|
||||
Some(AdjustedInput::DropToShellInThisPane)
|
||||
Some(AdjustedInput::DropToShellInThisPane { working_dir })
|
||||
},
|
||||
CTRL_C => Some(AdjustedInput::CloseThisPane),
|
||||
_ => None,
|
||||
|
@ -67,7 +67,11 @@ pub enum PtyInstruction {
|
||||
ClosePane(PaneId),
|
||||
CloseTab(Vec<PaneId>),
|
||||
ReRunCommandInPane(PaneId, RunCommand),
|
||||
DropToShellInPane(PaneId, Option<PathBuf>), // Option<PathBuf> - default shell
|
||||
DropToShellInPane {
|
||||
pane_id: PaneId,
|
||||
shell: Option<PathBuf>,
|
||||
working_dir: Option<PathBuf>,
|
||||
},
|
||||
SpawnInPlaceTerminal(
|
||||
Option<TerminalAction>,
|
||||
Option<String>,
|
||||
@ -101,7 +105,7 @@ impl From<&PtyInstruction> for PtyContext {
|
||||
PtyInstruction::CloseTab(_) => PtyContext::CloseTab,
|
||||
PtyInstruction::NewTab(..) => PtyContext::NewTab,
|
||||
PtyInstruction::ReRunCommandInPane(..) => PtyContext::ReRunCommandInPane,
|
||||
PtyInstruction::DropToShellInPane(..) => PtyContext::DropToShellInPane,
|
||||
PtyInstruction::DropToShellInPane { .. } => PtyContext::DropToShellInPane,
|
||||
PtyInstruction::SpawnInPlaceTerminal(..) => PtyContext::SpawnInPlaceTerminal,
|
||||
PtyInstruction::DumpLayout(..) => PtyContext::DumpLayout,
|
||||
PtyInstruction::LogLayoutToHd(..) => PtyContext::LogLayoutToHd,
|
||||
@ -546,17 +550,21 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
|
||||
},
|
||||
}
|
||||
},
|
||||
PtyInstruction::DropToShellInPane(pane_id, default_shell) => {
|
||||
PtyInstruction::DropToShellInPane {
|
||||
pane_id,
|
||||
shell,
|
||||
working_dir,
|
||||
} => {
|
||||
let err_context = || format!("failed to rerun command in pane {:?}", pane_id);
|
||||
|
||||
// TODO: get configured default_shell from screen/tab as an option and default to
|
||||
// this otherwise (also look for a place that turns get_default_shell into a
|
||||
// RunCommand, we might have done this before)
|
||||
let run_command = RunCommand {
|
||||
command: default_shell.unwrap_or_else(|| get_default_shell()),
|
||||
command: shell.unwrap_or_else(|| get_default_shell()),
|
||||
hold_on_close: false,
|
||||
hold_on_start: false,
|
||||
// TODO: cwd
|
||||
cwd: working_dir,
|
||||
..Default::default()
|
||||
};
|
||||
match pty
|
||||
|
@ -486,7 +486,7 @@ pub enum AdjustedInput {
|
||||
ReRunCommandInThisPane(RunCommand),
|
||||
PermissionRequestResult(Vec<PermissionType>, PermissionStatus),
|
||||
CloseThisPane,
|
||||
DropToShellInThisPane,
|
||||
DropToShellInThisPane { working_dir: Option<PathBuf> },
|
||||
}
|
||||
pub fn get_next_terminal_position(
|
||||
tiled_panes: &TiledPanes,
|
||||
@ -1736,13 +1736,14 @@ impl Tab {
|
||||
self.close_pane(PaneId::Terminal(active_terminal_id), false, None);
|
||||
should_update_ui = true;
|
||||
},
|
||||
Some(AdjustedInput::DropToShellInThisPane) => {
|
||||
Some(AdjustedInput::DropToShellInThisPane { working_dir }) => {
|
||||
self.pids_waiting_resize.insert(active_terminal_id);
|
||||
self.senders
|
||||
.send_to_pty(PtyInstruction::DropToShellInPane(
|
||||
PaneId::Terminal(active_terminal_id),
|
||||
self.default_shell.clone(),
|
||||
))
|
||||
.send_to_pty(PtyInstruction::DropToShellInPane {
|
||||
pane_id: PaneId::Terminal(active_terminal_id),
|
||||
shell: self.default_shell.clone(),
|
||||
working_dir,
|
||||
})
|
||||
.with_context(err_context)?;
|
||||
should_update_ui = true;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user