feat(panes): reuse CWD when dropping to shell in command panes (#2915)
This commit is contained in:
parent
83cf6d6e7c
commit
261c75ab92
3 changed files with 23 additions and 12 deletions
|
|
@ -196,11 +196,13 @@ impl Pane for TerminalPane {
|
||||||
Some(AdjustedInput::ReRunCommandInThisPane(run_command))
|
Some(AdjustedInput::ReRunCommandInThisPane(run_command))
|
||||||
},
|
},
|
||||||
ESC => {
|
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.is_held = None;
|
||||||
self.grid.reset_terminal_state();
|
self.grid.reset_terminal_state();
|
||||||
self.set_should_render(true);
|
self.set_should_render(true);
|
||||||
self.remove_banner();
|
self.remove_banner();
|
||||||
Some(AdjustedInput::DropToShellInThisPane)
|
Some(AdjustedInput::DropToShellInThisPane { working_dir })
|
||||||
},
|
},
|
||||||
CTRL_C => Some(AdjustedInput::CloseThisPane),
|
CTRL_C => Some(AdjustedInput::CloseThisPane),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,11 @@ pub enum PtyInstruction {
|
||||||
ClosePane(PaneId),
|
ClosePane(PaneId),
|
||||||
CloseTab(Vec<PaneId>),
|
CloseTab(Vec<PaneId>),
|
||||||
ReRunCommandInPane(PaneId, RunCommand),
|
ReRunCommandInPane(PaneId, RunCommand),
|
||||||
DropToShellInPane(PaneId, Option<PathBuf>), // Option<PathBuf> - default shell
|
DropToShellInPane {
|
||||||
|
pane_id: PaneId,
|
||||||
|
shell: Option<PathBuf>,
|
||||||
|
working_dir: Option<PathBuf>,
|
||||||
|
},
|
||||||
SpawnInPlaceTerminal(
|
SpawnInPlaceTerminal(
|
||||||
Option<TerminalAction>,
|
Option<TerminalAction>,
|
||||||
Option<String>,
|
Option<String>,
|
||||||
|
|
@ -101,7 +105,7 @@ impl From<&PtyInstruction> for PtyContext {
|
||||||
PtyInstruction::CloseTab(_) => PtyContext::CloseTab,
|
PtyInstruction::CloseTab(_) => PtyContext::CloseTab,
|
||||||
PtyInstruction::NewTab(..) => PtyContext::NewTab,
|
PtyInstruction::NewTab(..) => PtyContext::NewTab,
|
||||||
PtyInstruction::ReRunCommandInPane(..) => PtyContext::ReRunCommandInPane,
|
PtyInstruction::ReRunCommandInPane(..) => PtyContext::ReRunCommandInPane,
|
||||||
PtyInstruction::DropToShellInPane(..) => PtyContext::DropToShellInPane,
|
PtyInstruction::DropToShellInPane { .. } => PtyContext::DropToShellInPane,
|
||||||
PtyInstruction::SpawnInPlaceTerminal(..) => PtyContext::SpawnInPlaceTerminal,
|
PtyInstruction::SpawnInPlaceTerminal(..) => PtyContext::SpawnInPlaceTerminal,
|
||||||
PtyInstruction::DumpLayout(..) => PtyContext::DumpLayout,
|
PtyInstruction::DumpLayout(..) => PtyContext::DumpLayout,
|
||||||
PtyInstruction::LogLayoutToHd(..) => PtyContext::LogLayoutToHd,
|
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);
|
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
|
// 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
|
// this otherwise (also look for a place that turns get_default_shell into a
|
||||||
// RunCommand, we might have done this before)
|
// RunCommand, we might have done this before)
|
||||||
let run_command = RunCommand {
|
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_close: false,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
// TODO: cwd
|
cwd: working_dir,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
match pty
|
match pty
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,7 @@ pub enum AdjustedInput {
|
||||||
ReRunCommandInThisPane(RunCommand),
|
ReRunCommandInThisPane(RunCommand),
|
||||||
PermissionRequestResult(Vec<PermissionType>, PermissionStatus),
|
PermissionRequestResult(Vec<PermissionType>, PermissionStatus),
|
||||||
CloseThisPane,
|
CloseThisPane,
|
||||||
DropToShellInThisPane,
|
DropToShellInThisPane { working_dir: Option<PathBuf> },
|
||||||
}
|
}
|
||||||
pub fn get_next_terminal_position(
|
pub fn get_next_terminal_position(
|
||||||
tiled_panes: &TiledPanes,
|
tiled_panes: &TiledPanes,
|
||||||
|
|
@ -1736,13 +1736,14 @@ impl Tab {
|
||||||
self.close_pane(PaneId::Terminal(active_terminal_id), false, None);
|
self.close_pane(PaneId::Terminal(active_terminal_id), false, None);
|
||||||
should_update_ui = true;
|
should_update_ui = true;
|
||||||
},
|
},
|
||||||
Some(AdjustedInput::DropToShellInThisPane) => {
|
Some(AdjustedInput::DropToShellInThisPane { working_dir }) => {
|
||||||
self.pids_waiting_resize.insert(active_terminal_id);
|
self.pids_waiting_resize.insert(active_terminal_id);
|
||||||
self.senders
|
self.senders
|
||||||
.send_to_pty(PtyInstruction::DropToShellInPane(
|
.send_to_pty(PtyInstruction::DropToShellInPane {
|
||||||
PaneId::Terminal(active_terminal_id),
|
pane_id: PaneId::Terminal(active_terminal_id),
|
||||||
self.default_shell.clone(),
|
shell: self.default_shell.clone(),
|
||||||
))
|
working_dir,
|
||||||
|
})
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
should_update_ui = true;
|
should_update_ui = true;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue