Bail and signal error when the cwd of a resolved task doesn't exist (#32777)
Closes #32688 Release Notes: - Fixed tasks (including build tasks for debug configurations) silently using `/` as a working directory when the specified `cwd` didn't exist.
This commit is contained in:
parent
0f0ff40c6d
commit
22a2ff4f12
6 changed files with 54 additions and 4 deletions
|
@ -1461,10 +1461,27 @@ impl workspace::TerminalProvider for TerminalProvider {
|
|||
&self,
|
||||
task: SpawnInTerminal,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
cx: &mut Context<Workspace>,
|
||||
) -> Task<Option<Result<ExitStatus>>> {
|
||||
let terminal_panel = self.0.clone();
|
||||
let workspace = cx.weak_entity();
|
||||
window.spawn(cx, async move |cx| {
|
||||
if let Some(cwd) = task.cwd.as_deref() {
|
||||
let result = match smol::fs::metadata(cwd).await {
|
||||
Ok(metadata) if metadata.is_dir() => Ok(()),
|
||||
Ok(_) => Err(anyhow!("cwd for resolved task is not a directory: {cwd:?}")),
|
||||
Err(e) => Err(e).context(format!("reading cwd of resolved task: {cwd:?}")),
|
||||
};
|
||||
if let Err(e) = result {
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
workspace.show_error(&e, cx);
|
||||
})
|
||||
.ok();
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
let terminal = terminal_panel
|
||||
.update_in(cx, |terminal_panel, window, cx| {
|
||||
terminal_panel.spawn_task(&task, window, cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue