Fixed bugs in workflow step preview (#16445)

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-08-18 22:18:04 -07:00 committed by GitHub
parent 43e13df9f3
commit 86efde4b76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 109 additions and 42 deletions

View file

@ -2618,6 +2618,33 @@ impl Workspace {
open_project_item
}
pub fn find_project_item<T>(
&self,
pane: &View<Pane>,
project_item: &Model<T::Item>,
cx: &AppContext,
) -> Option<View<T>>
where
T: ProjectItem,
{
use project::Item as _;
let project_item = project_item.read(cx);
let entry_id = project_item.entry_id(cx);
let project_path = project_item.project_path(cx);
let mut item = None;
if let Some(entry_id) = entry_id {
item = pane.read(cx).item_for_entry(entry_id, cx);
}
if item.is_none() {
if let Some(project_path) = project_path {
item = pane.read(cx).item_for_path(project_path, cx);
}
}
item.and_then(|item| item.downcast::<T>())
}
pub fn is_project_item_open<T>(
&self,
pane: &View<Pane>,
@ -2627,13 +2654,7 @@ impl Workspace {
where
T: ProjectItem,
{
use project::Item as _;
project_item
.read(cx)
.entry_id(cx)
.and_then(|entry_id| pane.read(cx).item_for_entry(entry_id, cx))
.and_then(|item| item.downcast::<T>())
self.find_project_item::<T>(pane, project_item, cx)
.is_some()
}
@ -2648,19 +2669,12 @@ impl Workspace {
where
T: ProjectItem,
{
use project::Item as _;
let entry_id = project_item.read(cx).entry_id(cx);
if let Some(item) = entry_id
.and_then(|entry_id| pane.read(cx).item_for_entry(entry_id, cx))
.and_then(|item| item.downcast())
{
if let Some(item) = self.find_project_item(&pane, &project_item, cx) {
self.activate_item(&item, activate_pane, focus_item, cx);
return item;
}
let item = cx.new_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
let item_id = item.item_id();
let mut destination_index = None;
pane.update(cx, |pane, cx| {