Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/agent_ui/src/agent_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,13 @@ impl Item for AgentDiffPane {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| Self::new(self.thread.clone(), self.workspace.clone(), window, cx)))
Task::ready(Some(cx.new(|cx| {
Self::new(self.thread.clone(), self.workspace.clone(), window, cx)
})))
}

fn is_dirty(&self, cx: &App) -> bool {
Expand Down
44 changes: 25 additions & 19 deletions crates/collab/src/tests/following_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,26 +776,30 @@ async fn test_peers_following_each_other(cx_a: &mut TestAppContext, cx_b: &mut T
.unwrap();

// Clients A and B follow each other in split panes
workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.split_and_clone(
workspace.active_pane().clone(),
SplitDirection::Right,
window,
cx,
);
});
workspace_a
.update_in(cx_a, |workspace, window, cx| {
workspace.split_and_clone(
workspace.active_pane().clone(),
SplitDirection::Right,
window,
cx,
)
})
.await;
workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.follow(client_b.peer_id().unwrap(), window, cx)
});
executor.run_until_parked();
workspace_b.update_in(cx_b, |workspace, window, cx| {
workspace.split_and_clone(
workspace.active_pane().clone(),
SplitDirection::Right,
window,
cx,
);
});
workspace_b
.update_in(cx_b, |workspace, window, cx| {
workspace.split_and_clone(
workspace.active_pane().clone(),
SplitDirection::Right,
window,
cx,
)
})
.await;
workspace_b.update_in(cx_b, |workspace, window, cx| {
workspace.follow(client_a.peer_id().unwrap(), window, cx)
});
Expand Down Expand Up @@ -1369,9 +1373,11 @@ async fn test_auto_unfollowing(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont
);

// When client B activates a different pane, it continues following client A in the original pane.
workspace_b.update_in(cx_b, |workspace, window, cx| {
workspace.split_and_clone(pane_b.clone(), SplitDirection::Right, window, cx)
});
workspace_b
.update_in(cx_b, |workspace, window, cx| {
workspace.split_and_clone(pane_b.clone(), SplitDirection::Right, window, cx)
})
.await;
assert_eq!(
workspace_b.update(cx_b, |workspace, _| workspace.leader_for_pane(&pane_b)),
Some(leader_id.into())
Expand Down
2 changes: 1 addition & 1 deletion crates/collab/src/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6748,7 +6748,7 @@ async fn test_preview_tabs(cx: &mut TestAppContext) {
pane.update(cx, |pane, cx| {
pane.split(workspace::SplitDirection::Right, cx);
});

cx.run_until_parked();
let right_pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());

pane.update(cx, |pane, cx| {
Expand Down
6 changes: 3 additions & 3 deletions crates/collab_ui/src/channel_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ impl Item for ChannelView {
_: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>> {
Some(cx.new(|cx| {
) -> Task<Option<Entity<Self>>> {
Task::ready(Some(cx.new(|cx| {
Self::new(
self.project.clone(),
self.workspace.clone(),
Expand All @@ -508,7 +508,7 @@ impl Item for ChannelView {
window,
cx,
)
}))
})))
}

fn navigate(
Expand Down
6 changes: 3 additions & 3 deletions crates/diagnostics/src/buffer_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,11 @@ impl Item for BufferDiagnosticsEditor {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| {
Task::ready(Some(cx.new(|cx| {
BufferDiagnosticsEditor::new(
self.project_path.clone(),
self.project.clone(),
Expand All @@ -706,7 +706,7 @@ impl Item for BufferDiagnosticsEditor {
window,
cx,
)
}))
})))
}

fn deactivated(&mut self, window: &mut Window, cx: &mut Context<Self>) {
Expand Down
6 changes: 3 additions & 3 deletions crates/diagnostics/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,19 +732,19 @@ impl Item for ProjectDiagnosticsEditor {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| {
Task::ready(Some(cx.new(|cx| {
ProjectDiagnosticsEditor::new(
self.include_warnings,
self.project.clone(),
self.workspace.clone(),
window,
cx,
)
}))
})))
}

fn is_dirty(&self, cx: &App) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ impl Item for Editor {
_workspace_id: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Editor>>
) -> Task<Option<Entity<Editor>>>
where
Self: Sized,
{
Some(cx.new(|cx| self.clone(window, cx)))
Task::ready(Some(cx.new(|cx| self.clone(window, cx))))
}

fn set_nav_history(
Expand Down
10 changes: 5 additions & 5 deletions crates/git_ui/src/commit_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use editor::{Editor, EditorEvent, MultiBuffer, SelectionEffects, multibuffer_con
use git::repository::{CommitDetails, CommitDiff, RepoPath};
use gpui::{
Action, AnyElement, AnyView, App, AppContext as _, AsyncApp, AsyncWindowContext, Context,
Entity, EventEmitter, FocusHandle, Focusable, IntoElement, PromptLevel, Render, WeakEntity,
Window, actions,
Entity, EventEmitter, FocusHandle, Focusable, IntoElement, PromptLevel, Render, Task,
WeakEntity, Window, actions,
};
use language::{
Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, OffsetRangeExt as _,
Expand Down Expand Up @@ -561,11 +561,11 @@ impl Item for CommitView {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| {
Task::ready(Some(cx.new(|cx| {
let editor = cx.new(|cx| {
self.editor
.update(cx, |editor, cx| editor.clone(window, cx))
Expand All @@ -577,7 +577,7 @@ impl Item for CommitView {
commit: self.commit.clone(),
stash: self.stash,
}
}))
})))
}
}

Expand Down
10 changes: 7 additions & 3 deletions crates/git_ui/src/project_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,16 @@ impl Item for ProjectDiff {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
let workspace = self.workspace.upgrade()?;
Some(cx.new(|cx| ProjectDiff::new(self.project.clone(), workspace, window, cx)))
let Some(workspace) = self.workspace.upgrade() else {
return Task::ready(None);
};
Task::ready(Some(cx.new(|cx| {
ProjectDiff::new(self.project.clone(), workspace, window, cx)
})))
}

fn is_dirty(&self, cx: &App) -> bool {
Expand Down
6 changes: 3 additions & 3 deletions crates/image_viewer/src/image_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ impl Item for ImageView {
_workspace_id: Option<WorkspaceId>,
_: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| Self {
Task::ready(Some(cx.new(|cx| Self {
image_item: self.image_item.clone(),
project: self.project.clone(),
focus_handle: cx.focus_handle(),
}))
})))
}

fn has_deleted_file(&self, cx: &App) -> bool {
Expand Down
7 changes: 4 additions & 3 deletions crates/language_tools/src/key_context_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use gpui::{
Action, App, AppContext as _, Entity, EventEmitter, FocusHandle, Focusable,
KeyBindingContextPredicate, KeyContext, Keystroke, MouseButton, Render, Subscription, actions,
KeyBindingContextPredicate, KeyContext, Keystroke, MouseButton, Render, Subscription, Task,
actions,
};
use itertools::Itertools;
use serde_json::json;
Expand Down Expand Up @@ -157,11 +158,11 @@ impl Item for KeyContextView {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| KeyContextView::new(window, cx)))
Task::ready(Some(cx.new(|cx| KeyContextView::new(window, cx))))
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/language_tools/src/lsp_log_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use copilot::Copilot;
use editor::{Editor, EditorEvent, actions::MoveToEnd, scroll::Autoscroll};
use gpui::{
AnyView, App, Context, Corner, Entity, EventEmitter, FocusHandle, Focusable, IntoElement,
ParentElement, Render, Styled, Subscription, WeakEntity, Window, actions, div,
ParentElement, Render, Styled, Subscription, Task, WeakEntity, Window, actions, div,
};
use itertools::Itertools;
use language::{LanguageServerId, language_settings::SoftWrap};
Expand Down Expand Up @@ -763,11 +763,11 @@ impl Item for LspLogView {
_workspace_id: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| {
Task::ready(Some(cx.new(|cx| {
let mut new_view = Self::new(self.project.clone(), self.log_store.clone(), window, cx);
if let Some(server_id) = self.current_server_id {
match self.active_entry_kind {
Expand All @@ -778,7 +778,7 @@ impl Item for LspLogView {
}
}
new_view
}))
})))
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/language_tools/src/syntax_tree_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use editor::{Anchor, Editor, ExcerptId, SelectionEffects, scroll::Autoscroll};
use gpui::{
App, AppContext as _, Context, Div, Entity, EntityId, EventEmitter, FocusHandle, Focusable,
Hsla, InteractiveElement, IntoElement, MouseButton, MouseDownEvent, MouseMoveEvent,
ParentElement, Render, ScrollStrategy, SharedString, Styled, UniformListScrollHandle,
ParentElement, Render, ScrollStrategy, SharedString, Styled, Task, UniformListScrollHandle,
WeakEntity, Window, actions, div, rems, uniform_list,
};
use language::{Buffer, OwnedSyntaxLayer};
Expand Down Expand Up @@ -573,17 +573,17 @@ impl Item for SyntaxTreeView {
_: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| {
Task::ready(Some(cx.new(|cx| {
let mut clone = Self::new(self.workspace_handle.clone(), None, window, cx);
if let Some(editor) = &self.editor {
clone.set_editor(editor.editor.clone(), window, cx)
}
clone
}))
})))
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/onboarding/src/onboarding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ impl Item for Onboarding {
_workspace_id: Option<WorkspaceId>,
_: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>> {
Some(cx.new(|cx| Onboarding {
) -> Task<Option<Entity<Self>>> {
Task::ready(Some(cx.new(|cx| Onboarding {
workspace: self.workspace.clone(),
user_store: self.user_store.clone(),
scroll_handle: ScrollHandle::new(),
focus_handle: cx.focus_handle(),
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
}))
})))
}

fn to_item_events(event: &Self::Event, mut f: impl FnMut(workspace::item::ItemEvent)) {
Expand Down
6 changes: 4 additions & 2 deletions crates/repl/src/notebook/notebook_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,13 @@ impl Item for NotebookEditor {
_workspace_id: Option<workspace::WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
Some(cx.new(|cx| Self::new(self.project.clone(), self.notebook_item.clone(), window, cx)))
Task::ready(Some(cx.new(|cx| {
Self::new(self.project.clone(), self.notebook_item.clone(), window, cx)
})))
}

fn buffer_kind(&self, _: &App) -> workspace::item::ItemBufferKind {
Expand Down
8 changes: 6 additions & 2 deletions crates/search/src/project_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,14 @@ impl Item for ProjectSearchView {
_workspace_id: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>>
) -> Task<Option<Entity<Self>>>
where
Self: Sized,
{
let model = self.entity.update(cx, |model, cx| model.clone(cx));
Some(cx.new(|cx| Self::new(self.workspace.clone(), model, window, cx, None)))
Task::ready(Some(cx.new(|cx| {
Self::new(self.workspace.clone(), model, window, cx, None)
})))
}

fn added_to_workspace(
Expand Down Expand Up @@ -3677,6 +3679,7 @@ pub mod tests {
)
})
.unwrap()
.await
.unwrap();
assert_eq!(cx.update(|cx| second_pane.read(cx).items_len()), 1);

Expand Down Expand Up @@ -3872,6 +3875,7 @@ pub mod tests {
)
})
.unwrap()
.await
.unwrap();
assert_eq!(cx.update(|cx| second_pane.read(cx).items_len()), 1);
assert!(
Expand Down
Loading
Loading