toolchains: Add support for relative paths (#27777)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-03-31 19:48:09 +02:00 committed by GitHub
parent 627ae7af6f
commit edf712d45b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 178 additions and 93 deletions

View file

@ -1,10 +1,12 @@
use std::sync::Arc;
use editor::Editor;
use gpui::{
div, AsyncWindowContext, Context, Entity, IntoElement, ParentElement, Render, Subscription,
Task, WeakEntity, Window,
};
use language::{Buffer, BufferEvent, LanguageName, Toolchain};
use project::{Project, WorktreeId};
use project::{Project, ProjectPath, WorktreeId};
use ui::{Button, ButtonCommon, Clickable, FluentBuilder, LabelSize, SharedString, Tooltip};
use workspace::{item::ItemHandle, StatusItemView, Workspace};
@ -109,9 +111,14 @@ impl ActiveToolchain {
.flatten()?;
let selected_toolchain = workspace
.update(cx, |this, cx| {
this.project()
.read(cx)
.active_toolchain(worktree_id, language_name.clone(), cx)
this.project().read(cx).active_toolchain(
ProjectPath {
worktree_id,
path: Arc::from("".as_ref()),
},
language_name.clone(),
cx,
)
})
.ok()?
.await;
@ -123,21 +130,33 @@ impl ActiveToolchain {
.ok()?;
let toolchains = cx
.update(|_, cx| {
project
.read(cx)
.available_toolchains(worktree_id, language_name, cx)
project.read(cx).available_toolchains(
ProjectPath {
worktree_id,
path: Arc::from("".as_ref()),
},
language_name,
cx,
)
})
.ok()?
.await?;
if let Some(toolchain) = toolchains.toolchains.first() {
// Since we don't have a selected toolchain, pick one for user here.
workspace::WORKSPACE_DB
.set_toolchain(workspace_id, worktree_id, toolchain.clone())
.set_toolchain(workspace_id, worktree_id, "".to_owned(), toolchain.clone())
.await
.ok()?;
project
.update(cx, |this, cx| {
this.activate_toolchain(worktree_id, toolchain.clone(), cx)
this.activate_toolchain(
ProjectPath {
worktree_id,
path: Arc::from("".as_ref()),
},
toolchain.clone(),
cx,
)
})
.ok()?
.await;

View file

@ -9,7 +9,7 @@ use gpui::{
};
use language::{LanguageName, Toolchain, ToolchainList};
use picker::{Picker, PickerDelegate};
use project::{Project, WorktreeId};
use project::{Project, ProjectPath, WorktreeId};
use std::{path::Path, sync::Arc};
use ui::{prelude::*, HighlightedLabel, ListItem, ListItemSpacing};
use util::ResultExt;
@ -169,7 +169,14 @@ impl ToolchainSelectorDelegate {
});
let available_toolchains = project
.update(cx, |this, cx| {
this.available_toolchains(worktree_id, language_name, cx)
this.available_toolchains(
ProjectPath {
worktree_id,
path: Arc::from("".as_ref()),
},
language_name,
cx,
)
})
.ok()?
.await?;
@ -241,13 +248,20 @@ impl PickerDelegate for ToolchainSelectorDelegate {
let worktree_id = self.worktree_id;
cx.spawn_in(window, async move |_, cx| {
workspace::WORKSPACE_DB
.set_toolchain(workspace_id, worktree_id, toolchain.clone())
.set_toolchain(workspace_id, worktree_id, "".to_owned(), toolchain.clone())
.await
.log_err();
workspace
.update(cx, |this, cx| {
this.project().update(cx, |this, cx| {
this.activate_toolchain(worktree_id, toolchain, cx)
this.activate_toolchain(
ProjectPath {
worktree_id,
path: Arc::from("".as_ref()),
},
toolchain,
cx,
)
})
})
.ok()?