terminal: Do not auto close shell terminals if they error out (#38182)

Closes https://github.com/zed-industries/zed/issues/38134

This also reduces an annoying level of shell nesting

Release Notes:

- N/A
This commit is contained in:
Lukas Wirth
2025-09-15 10:09:25 +00:00
committed by GitHub
parent 4a582504d4
commit 393d6787a3
2 changed files with 165 additions and 73 deletions
+11 -15
View File
@@ -769,13 +769,11 @@ impl RemoteClient {
}
pub fn shell(&self) -> Option<String> {
Some(self.state.as_ref()?.remote_connection()?.shell())
Some(self.remote_connection()?.shell())
}
pub fn shares_network_interface(&self) -> bool {
self.state
.as_ref()
.and_then(|state| state.remote_connection())
self.remote_connection()
.map_or(false, |connection| connection.shares_network_interface())
}
@@ -787,12 +785,8 @@ impl RemoteClient {
working_dir: Option<String>,
port_forward: Option<(u16, String, u16)>,
) -> Result<CommandTemplate> {
let Some(connection) = self
.state
.as_ref()
.and_then(|state| state.remote_connection())
else {
return Err(anyhow!("no connection"));
let Some(connection) = self.remote_connection() else {
return Err(anyhow!("no ssh connection"));
};
connection.build_command(program, args, env, working_dir, port_forward)
}
@@ -803,11 +797,7 @@ impl RemoteClient {
dest_path: RemotePathBuf,
cx: &App,
) -> Task<Result<()>> {
let Some(connection) = self
.state
.as_ref()
.and_then(|state| state.remote_connection())
else {
let Some(connection) = self.remote_connection() else {
return Task::ready(Err(anyhow!("no ssh connection")));
};
connection.upload_directory(src_path, dest_path, cx)
@@ -916,6 +906,12 @@ impl RemoteClient {
.unwrap()
.unwrap()
}
fn remote_connection(&self) -> Option<Arc<dyn RemoteConnection>> {
self.state
.as_ref()
.and_then(|state| state.remote_connection())
}
}
enum ConnectionPoolEntry {