toolchains: Add support for relative paths (#27777)
Closes #ISSUE Release Notes: - N/A
This commit is contained in:
parent
627ae7af6f
commit
edf712d45b
12 changed files with 178 additions and 93 deletions
|
@ -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;
|
||||
|
|
|
@ -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()?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue