acp_thread: Properly use project terminal API (#38186)
Closes https://github.com/zed-industries/zed/issues/35603 Release Notes: - Fixed shell selection for terminal tool
This commit is contained in:
@@ -772,6 +772,10 @@ impl RemoteClient {
|
||||
Some(self.remote_connection()?.shell())
|
||||
}
|
||||
|
||||
pub fn default_system_shell(&self) -> Option<String> {
|
||||
Some(self.remote_connection()?.default_system_shell())
|
||||
}
|
||||
|
||||
pub fn shares_network_interface(&self) -> bool {
|
||||
self.remote_connection()
|
||||
.map_or(false, |connection| connection.shares_network_interface())
|
||||
@@ -1062,6 +1066,7 @@ pub(crate) trait RemoteConnection: Send + Sync {
|
||||
fn connection_options(&self) -> RemoteConnectionOptions;
|
||||
fn path_style(&self) -> PathStyle;
|
||||
fn shell(&self) -> String;
|
||||
fn default_system_shell(&self) -> String;
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn simulate_disconnect(&self, _: &AsyncApp) {}
|
||||
@@ -1503,6 +1508,10 @@ mod fake {
|
||||
fn shell(&self) -> String {
|
||||
"sh".to_owned()
|
||||
}
|
||||
|
||||
fn default_system_shell(&self) -> String {
|
||||
"sh".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Delegate;
|
||||
|
||||
@@ -37,6 +37,7 @@ pub(crate) struct SshRemoteConnection {
|
||||
ssh_platform: RemotePlatform,
|
||||
ssh_path_style: PathStyle,
|
||||
ssh_shell: String,
|
||||
ssh_default_system_shell: String,
|
||||
_temp_dir: TempDir,
|
||||
}
|
||||
|
||||
@@ -105,6 +106,10 @@ impl RemoteConnection for SshRemoteConnection {
|
||||
self.ssh_shell.clone()
|
||||
}
|
||||
|
||||
fn default_system_shell(&self) -> String {
|
||||
self.ssh_default_system_shell.clone()
|
||||
}
|
||||
|
||||
fn build_command(
|
||||
&self,
|
||||
input_program: Option<String>,
|
||||
@@ -347,6 +352,7 @@ impl SshRemoteConnection {
|
||||
_ => PathStyle::Posix,
|
||||
};
|
||||
let ssh_shell = socket.shell().await;
|
||||
let ssh_default_system_shell = String::from("/bin/sh");
|
||||
|
||||
let mut this = Self {
|
||||
socket,
|
||||
@@ -356,6 +362,7 @@ impl SshRemoteConnection {
|
||||
ssh_path_style,
|
||||
ssh_platform,
|
||||
ssh_shell,
|
||||
ssh_default_system_shell,
|
||||
};
|
||||
|
||||
let (release_channel, version, commit) = cx.update(|cx| {
|
||||
|
||||
@@ -29,6 +29,7 @@ pub(crate) struct WslRemoteConnection {
|
||||
remote_binary_path: Option<RemotePathBuf>,
|
||||
platform: RemotePlatform,
|
||||
shell: String,
|
||||
default_system_shell: String,
|
||||
connection_options: WslConnectionOptions,
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ impl WslRemoteConnection {
|
||||
remote_binary_path: None,
|
||||
platform: RemotePlatform { os: "", arch: "" },
|
||||
shell: String::new(),
|
||||
default_system_shell: String::from("/bin/sh"),
|
||||
};
|
||||
delegate.set_status(Some("Detecting WSL environment"), cx);
|
||||
this.platform = this.detect_platform().await?;
|
||||
@@ -84,7 +86,11 @@ impl WslRemoteConnection {
|
||||
.run_wsl_command("sh", &["-c", "echo $SHELL"])
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|shell_path| shell_path.trim().split('/').next_back().map(str::to_string))
|
||||
.and_then(|shell_path| {
|
||||
Path::new(shell_path.trim())
|
||||
.file_name()
|
||||
.map(|it| it.to_str().unwrap().to_owned())
|
||||
})
|
||||
.unwrap_or_else(|| "bash".to_string()))
|
||||
}
|
||||
|
||||
@@ -427,6 +433,10 @@ impl RemoteConnection for WslRemoteConnection {
|
||||
fn shell(&self) -> String {
|
||||
self.shell.clone()
|
||||
}
|
||||
|
||||
fn default_system_shell(&self) -> String {
|
||||
self.default_system_shell.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// `wslpath` is a executable available in WSL, it's a linux binary.
|
||||
|
||||
Reference in New Issue
Block a user