util: Fix shell kind in windows based on program path (#39696)
Closes #39614 The `ShellKind` struct is built on Windows' side, meaning that when connecting to remotes, we fall back to PowerShell construction, even if the shell program we are spawning is a unix program. This broke tasks creation since we are using the shell kind to construct args: https://github.com/zed-industries/zed/blob/d04ac864b8cb78ee888ce03323e34c17a6dd16b9/crates/project/src/terminals.rs#L149 In normal terminals this only affected activation scripts (only place where shell kind is used) I don't have a Windows machine to test it, so I would appreciate any help with testing! Release Notes: - Fixed an issue where tasks could not be executed in Windows WSL --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
This commit is contained in:
@@ -526,23 +526,18 @@ impl TerminalPanel {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<WeakEntity<Terminal>>> {
|
||||
let remote_client = self
|
||||
.workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
let project = workspace.project().read(cx);
|
||||
if project.is_via_collab() {
|
||||
Err(anyhow!("cannot spawn tasks as a guest"))
|
||||
} else {
|
||||
Ok(project.remote_client())
|
||||
}
|
||||
})
|
||||
.flatten();
|
||||
|
||||
let remote_client = match remote_client {
|
||||
Ok(remote_client) => remote_client,
|
||||
Err(e) => return Task::ready(Err(e)),
|
||||
let Some(workspace) = self.workspace.upgrade() else {
|
||||
return Task::ready(Err(anyhow!("failed to read workspace")));
|
||||
};
|
||||
|
||||
let project = workspace.read(cx).project().read(cx);
|
||||
|
||||
if project.is_via_collab() {
|
||||
return Task::ready(Err(anyhow!("cannot spawn tasks as a guest")));
|
||||
}
|
||||
|
||||
let remote_client = project.remote_client();
|
||||
let is_windows = project.path_style(cx).is_windows();
|
||||
let remote_shell = remote_client
|
||||
.as_ref()
|
||||
.and_then(|remote_client| remote_client.read(cx).shell());
|
||||
@@ -555,7 +550,7 @@ impl TerminalPanel {
|
||||
task.shell.clone()
|
||||
};
|
||||
|
||||
let builder = ShellBuilder::new(&shell);
|
||||
let builder = ShellBuilder::new(&shell, is_windows);
|
||||
let command_label = builder.command_label(task.command.as_deref().unwrap_or(""));
|
||||
let (command, args) = builder.build(task.command.clone(), &task.args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user