id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_507100 | rust_dataset.txt | 507,100 | 512 | >,
focus_handle: gpui::FocusHandle,
pub child_focus_handles: Vec<gpui::FocusHandle>,
}
impl project::ProjectItem for TestProjectItem {
fn try_open(
_project: &Entity<Project>,
_path: &ProjectPath,
_cx: &mut App,
) -> Option<Task<anyhow::Result... |
rust_dataset_chunk_507101 | rust_dataset.txt | 507,101 | 512 | _count: 0,
reload_count: 0,
is_dirty: false,
save_error: None,
has_conflict: false,
has_deleted_file: false,
capability: Capability::ReadWrite,
project_items: Vec::new(),
buffer_kind: ItemBuff... |
rust_dataset_chunk_507102 | rust_dataset.txt | 507,102 | 512 | pub fn set_state(&mut self, state: String, cx: &mut Context<Self>) {
self.push_to_nav_history(cx);
self.state = state;
}
fn push_to_nav_history(&mut self, cx: &mut Context<Self>) {
if let Some(history) = &mut self.nav_history {
history.push(Some(Box:... |
rust_dataset_chunk_507103 | rust_dataset.txt | 507,103 | 512 | mut self,
history: ItemNavHistory,
_window: &mut Window,
_: &mut Context<Self>,
) {
self.nav_history = Some(history);
}
fn navigate(
&mut self,
state: Arc<dyn Any + Send>,
_window: &mut Window,
_: &m... |
rust_dataset_chunk_507104 | rust_dataset.txt | 507,104 | 512 | !self.project_items.is_empty()
&& self
.project_items
.iter()
.all(|item| item.read(cx).entry_id.is_some())
}
fn can_save_as(&self, _cx: &App) -> bool {
self.buffer_kind == ItemBufferKind::Singleton
... |
rust_dataset_chunk_507105 | rust_dataset.txt | 507,105 | 512 | mut Window,
_cx: &mut App,
) -> Task<anyhow::Result<()>> {
Task::ready(Ok(()))
}
fn serialize(
&mut self,
_workspace: &mut Workspace,
_item_id: ItemId,
_closing: bool,
_cx: &mut Context<Self>,
) -> Optio... |
rust_dataset_chunk_507106 | rust_dataset.txt | 507,106 | 512 | .upgrade())
.any(|handle| &handle == focus_handle)
})
}
pub trait ModalView: ManagedView {
fn on_before_dismiss(
&mut self,
_window: &mut Window,
_: &mut Context<Self>,
) -> DismissDecision {
DismissDecision::Dismiss(true)
}
fn fade_out_backgroun... |
rust_dataset_chunk_507107 | rust_dataset.txt | 507,107 | 512 | // Set when a reveal was requested while another modal was still active (e.g. one
// that is dismissed only after the reopen action fires). The reveal then happens
// once that modal closes, so it doesn't matter whether the triggering modal is
// dismissed before or after the action dispatches.
reveal_... |
rust_dataset_chunk_507108 | rust_dataset.txt | 507,108 | 512 | subscriptions for dismiss events and focus tracking.
/// The modal is automatically focused after being shown.
fn show_modal(
&mut self,
modal: Box<dyn ModalViewHandle>,
previous_focus_handle: Option<FocusHandle>,
window: &mut Window,
cx: &mut Context<Self>,
) {
... |
rust_dataset_chunk_507109 | rust_dataset.txt | 507,109 | 512 | _mut() else {
self.dismiss_on_focus_lost = false;
return false;
};
match active_modal.modal.on_before_dismiss(window, cx) {
DismissDecision::Dismiss(should_dismiss) => {
if !should_dismiss {
self.dismiss_on_focus_lost = !should_dis... |
rust_dataset_chunk_507110 | rust_dataset.txt | 507,110 | 512 | this.hide_modal(window, cx);
}),
)
.child(
v_flex()
.h(px(0.0))
.top_20()
.items_center()
.track_focus(&active_modal.focus_handle)
.child(
... |
rust_dataset_chunk_507111 | rust_dataset.txt | 507,111 | 512 | the active project down in the sidebar.
MoveProjectDown,
/// Activates the next thread in sidebar order.
NextThread,
/// Activates the previous thread in sidebar order.
PreviousThread,
/// Creates a new thread in the current workspace.
NewThread,
/// Move... |
rust_dataset_chunk_507112 | rust_dataset.txt | 507,112 | 512 | side(&self, _cx: &App) -> SidebarSide;
fn is_threads_list_view_active(&self) -> bool {
true
}
/// Whether the sidebar still lists, under the old group, saved threads or terminals that do not move with the re-keyed workspace.
fn retains_project_group(
&self,
_old_worktree_paths:... |
rust_dataset_chunk_507113 | rust_dataset.txt | 507,113 | 512 | EntityId;
fn toggle_thread_switcher(&self, select_last: bool, window: &mut Window, cx: &mut App);
fn cycle_project(&self, forward: bool, window: &mut Window, cx: &mut App);
fn cycle_thread(&self, forward: bool, window: &mut Window, cx: &mut App);
fn is_threads_list_view_active(&self, cx: &App) -> bool... |
rust_dataset_chunk_507114 | rust_dataset.txt | 507,114 | 512 | : &mut Window, cx: &mut App) {
let entity = self.clone();
window.defer(cx, move |window, cx| {
entity.update(cx, |this, cx| {
this.toggle_thread_switcher(select_last, window, cx);
});
});
}
fn cycle_project(&self, forward: bool, window: &mut Windo... |
rust_dataset_chunk_507115 | rust_dataset.txt | 507,115 | 512 | Project,
CloseProject,
}
/// One row per workspace held by this window. The displayed workspace is
/// always one of these rows. `pinned` records whether the workspace survives
/// being navigated away from; `activated_at` records when it was last
/// displayed.
struct HeldWorkspace {
workspace: Entity<Workspa... |
rust_dataset_chunk_507116 | rust_dataset.txt | 507,116 | 512 | _enabled = !DisableAiSettings::get_global(cx)
.disable_ai
&& AgentSettings::get_global(cx).enabled;
move |this, window, cx| {
let multi_workspace_enabled = this.multi_workspace_enabled(cx);
if previous_multi_workspace_enabled && !multi_workspac... |
rust_dataset_chunk_507117 | rust_dataset.txt | 507,117 | 512 | on every keystroke that leaves no pending input, and
// observers of this entity, like the agent panel's terminal notification, react to notify.
if popup.is_none() && self.pending_bindings_popup.is_none() {
return;
}
self.pending_bindings_popup = popup;
cx.notify();
... |
rust_dataset_chunk_507118 | rust_dataset.txt | 507,118 | 512 | .previous_focus_handle = window.focused(cx);
if let Some(sidebar) = &self.sidebar {
sidebar.prepare_for_focus(window, cx);
sidebar.focus(window, cx);
}
}
} else {
self.previous_focus_handle = window.focused(cx);
... |
rust_dataset_chunk_507119 | rust_dataset.txt | 507,119 | 512 | cx);
} else {
self.previous_focus_handle.take();
}
self.serialize(cx);
cx.notify();
}
fn restore_previous_focus(&mut self, clear: bool, window: &mut Window, cx: &mut Context<Self>) {
let focus_handle = if clear {
self.previous_focus_handle.take()... |
rust_dataset_chunk_507120 | rust_dataset.txt | 507,120 | 512 | _ => {}
}
})
.detach();
cx.subscribe_in(workspace, window, |this, workspace, event, window, cx| {
if let WorkspaceEvent::Activate = event {
this.activate(workspace.clone(), None, window, cx);
}
})
.detach();
... |
rust_dataset_chunk_507121 | rust_dataset.txt | 507,121 | 512 | if key.path_list().paths().is_empty() {
return;
}
if self.project_groups.iter().any(|group| group.key == key) {
return;
}
self.project_groups.insert(
0,
ProjectGroupState {
key,
expanded: true,
... |
rust_dataset_chunk_507122 | rust_dataset.txt | 507,122 | 512 | _index,
ProjectGroupState {
key: new_key.clone(),
expanded,
},
);
}
return;
}
if new_key_exists {
let active_key = self.workspace().read(cx).project_group_key(cx);... |
rust_dataset_chunk_507123 | rust_dataset.txt | 507,123 | 512 | );
self.pin(index, provisional_key, cx);
self.activate(workspace, None, window, cx);
}
fn register_workspace(
&mut self,
workspace: &Entity<Workspace>,
window: &Window,
cx: &mut Context<Self>,
) {
Self::subscribe_to_workspace(workspace, window, cx);
... |
rust_dataset_chunk_507124 | rust_dataset.txt | 507,124 | 512 | .insert(index, ProjectGroupState { key, expanded });
index += 1;
}
}
self.serialize(cx);
cx.notify();
}
pub fn project_group_keys(&self) -> Vec<ProjectGroupKey> {
self.project_groups
.iter()
.map(|group| gro... |
rust_dataset_chunk_507125 | rust_dataset.txt | 507,125 | 512 | Changed);
self.serialize(cx);
cx.notify();
true
}
pub fn move_project_group_down(
&mut self,
key: &ProjectGroupKey,
cx: &mut Context<Self>,
) -> bool {
let Some(index) = self
.project_groups
.iter()
.position(|group... |
rust_dataset_chunk_507126 | rust_dataset.txt | 507,126 | 512 | self.serialize(cx);
cx.notify();
return Task::ready(Ok(true));
}
return Task::ready(Ok(false));
}
self.remove(workspaces, RemovalIntent::CloseProject, window, cx)
}
/// Returns the nearest retained workspace outside the project group at
... |
rust_dataset_chunk_507127 | rust_dataset.txt | 507,127 | 512 | .is_empty() {
return Task::ready(Ok(()));
}
let app_state = self.workspace().read(cx).app_state().clone();
let workspaces: Vec<_> = self
.workspaces_for_project_group(key, cx)
.cloned()
.collect();
let mut serialization_tasks = Vec::new()... |
rust_dataset_chunk_507128 | rust_dataset.txt | 507,128 | 512 | : Option<RemoteConnectionOptions>,
provisional_project_group_key: Option<ProjectGroupKey>,
connect_remote: impl FnOnce(
RemoteConnectionOptions,
&mut Window,
&mut Context<Self>,
) -> Task<Result<Option<Entity<remote::RemoteClient>>>>
+ 'static,
... |
rust_dataset_chunk_507129 | rust_dataset.txt | 507,129 | 512 | This is a weaker guarantee than the local
// `Ok(None)` check, but it matches how the rest of the
// codebase consumes this API.
let all_paths_missing =
!paths_vec.is_empty() && resolved.iter().all(|resolved| resolved.is_none());
... |
rust_dataset_chunk_507130 | rust_dataset.txt | 507,130 | 512 | self.workspace().read(cx).app_state().clone();
let requesting_window = window.window_handle().downcast::<MultiWorkspace>();
let fs = <dyn Fs>::global(cx);
cx.spawn(async move |_this, cx| {
let effective_path_list = if let Some(project_group) = project_group {
let me... |
rust_dataset_chunk_507131 | rust_dataset.txt | 507,131 | 512 | discovery.
pub fn add(&mut self, workspace: Entity<Workspace>, window: &Window, cx: &mut Context<Self>) {
if self.is_workspace_retained(&workspace) {
return;
}
let key = workspace.read(cx).project_group_key(cx);
let index = self.hold(workspace, window, cx);
self.... |
rust_dataset_chunk_507132 | rust_dataset.txt | 507,132 | 512 | the newly-active
// workspace (which is now the chrome owner per `owns_window_chrome`).
workspace.update(cx, |workspace, cx| {
workspace.refresh_window_state(window, cx);
});
cx.emit(MultiWorkspaceEvent::ActiveWorkspaceChanged { source_workspace });
self.serialize(c... |
rust_dataset_chunk_507133 | rust_dataset.txt | 507,133 | 512 | ._serialize_workspace_task.take();
});
if let Some(workspace_id) = workspace.read(cx).database_id() {
let db = crate::persistence::WorkspaceDb::global(cx);
self.pending_removal_tasks.retain(|task| !task.is_ready());
self.pending_removal_tasks
.push(cx... |
rust_dataset_chunk_507134 | rust_dataset.txt | 507,134 | 512 | _pending_serialization(
&mut self,
window: &mut Window,
cx: &mut Context<Self>,
) -> Vec<Task<()>> {
let mut tasks = Vec::new();
for workspace in self.workspaces() {
tasks.push(workspace.update(cx, |workspace, cx| {
workspace.flush_serialization(wi... |
rust_dataset_chunk_507135 | rust_dataset.txt | 507,135 | 512 | ock(dock_side, window, cx);
});
}
pub fn active_item_as<I: 'static>(&self, cx: &App) -> Option<Entity<I>> {
self.workspace().read(cx).active_item_as::<I>(cx)
}
pub fn items_of_type<'a, T: Item>(
&'a self,
cx: &'a App,
) -> impl 'a + Iterator<Item = Entity<T>> {
... |
rust_dataset_chunk_507136 | rust_dataset.txt | 507,136 | 512 | "))]
pub fn test_new(project: Entity<Project>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let workspace = cx.new(|cx| Workspace::test_new(project, window, cx));
Self::new(workspace, window, cx)
}
#[cfg(any(test, feature = "test-support"))]
pub fn test_add_workspace(
... |
rust_dataset_chunk_507137 | rust_dataset.txt | 507,137 | 512 | (async move {
db.set_session_binding(workspace_id, session_id, Some(window_id))
.await
.log_err();
})
})
.unwrap();
task.await
})
}
/// Assigns random database... |
rust_dataset_chunk_507138 | rust_dataset.txt | 507,138 | 512 | or_else(|| {
self.held
.iter()
.filter(|held| held.pinned)
.map(|held| held.workspace.clone())
.filter(|workspace| workspace.read(cx).project_group_key(cx) == *key)
.find(available)
})
}
... |
rust_dataset_chunk_507139 | rust_dataset.txt | 507,139 | 512 | only; no state changes.
for workspace in &workspaces {
let should_continue = workspace
.update_in(cx, |workspace, window, cx| {
workspace.prepare_to_close(CloseIntent::ReplaceWindow, window, cx)
})?
.await?;... |
rust_dataset_chunk_507140 | rust_dataset.txt | 507,140 | 512 | neighbor_keys
.iter()
.find_map(|key| this.live_member_for_group(key, doomed, cx))
})
.unwrap_or_else(|| {
if reopen_key.is_none() {
reopen_key = a... |
rust_dataset_chunk_507141 | rust_dataset.txt | 507,141 | 512 | {
let should_continue = empty_workspace
.update_in(cx, |workspace, window, cx| {
workspace.prepare_to_close(CloseIntent::ReplaceWindow, window, cx)
})?
.await?;
if !should_continu... |
rust_dataset_chunk_507142 | rust_dataset.txt | 507,142 | 512 | await
.map(|result| result.workspace)
} else {
Ok(workspace)
}
})
}
}
}
impl Render for MultiWorkspace {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let multi_work... |
rust_dataset_chunk_507143 | rust_dataset.txt | 507,143 | 512 | {
(None, sidebar)
} else {
(sidebar, None)
};
let ui_font = theme_settings::setup_ui_font(window, cx);
let text_color = cx.theme().colors().text;
let workspace = self.workspace().clone();
let workspace_key_context = workspace.update(cx, |workspa... |
rust_dataset_chunk_507144 | rust_dataset.txt | 507,144 | 512 | , cx| {
if let Some(sidebar) = &this.sidebar {
sidebar.cycle_project(false, window, cx);
}
}),
)
.on_action(
cx.listener(|this: &mut Self, _: &M... |
rust_dataset_chunk_507145 | rust_dataset.txt | 507,145 | 512 | )
.child(self.workspace().read(cx).modal_layer.clone())
.children(self.sidebar_overlay.as_ref().map(|view| {
deferred(div().absolute().size_full().inset_0().occlude().child(
v_flex().h(px(0.0)).top_20().items_center().child(
... |
rust_dataset_chunk_507146 | rust_dataset.txt | 507,146 | 512 | .open_sidebar(cx));
cx.run_until_parked();
(multi_workspace, cx)
}
#[gpui::test]
async fn test_sidebar_disabled_when_disable_ai_is_enabled(cx: &mut TestAppContext) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
let project = Project::test(fs, [], cx).await;
let (multi_workspace, cx) =
... |
rust_dataset_chunk_507147 | rust_dataset.txt | 507,147 | 512 | _workspace_collapses_when_agent_is_disabled(cx: &mut TestAppContext) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
fs.insert_tree("/root_b", json!({ "file.txt": "" })).await;
let project_a = Project::test(fs.clone(), ["/root_a".as_r... |
rust_dataset_chunk_507148 | rust_dataset.txt | 507,148 | 512 | _keys();
assert_eq!(keys.len(), 1, "should have exactly one key on creation");
assert_eq!(keys[0], expected_key);
});
}
#[gpui::test]
async fn test_project_group_keys_add_workspace(cx: &mut TestAppContext) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
fs.insert_tree("/root_a", j... |
rust_dataset_chunk_507149 | rust_dataset.txt | 507,149 | 512 | ::test(fs.clone(), ["/root_a".as_ref()], cx).await;
let project_b = Project::test(fs, ["/root_b".as_ref()], cx).await;
let key_a = project_a.read_with(cx, |project, cx| project.project_group_key(cx));
let key_b = project_b.read_with(cx, |project, cx| project.project_group_key(cx));
let (multi_workspac... |
rust_dataset_chunk_507150 | rust_dataset.txt | 507,150 | 512 | unwrap();
cx.update(|cx| {
open_paths(
&[PathBuf::from(path!("/project_b"))],
app_state,
OpenOptions {
open_mode: OpenMode::NewWindow,
..OpenOptions::default()
},
cx,
)
})
.await
.unwrap();
... |
rust_dataset_chunk_507151 | rust_dataset.txt | 507,151 | 512 | settings.threads_sidebar.auto_open = false;
AgentSettings::override_global(settings, cx);
});
let project = Project::test(app_state.fs.clone(), [path!("/project_a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project, window, cx));
cx.run_until_parked... |
rust_dataset_chunk_507152 | rust_dataset.txt | 507,152 | 512 | | {
open_paths(
&[PathBuf::from(path!("/project"))],
app_state,
OpenOptions {
requesting_window: Some(window),
open_mode: OpenMode::Activate,
..OpenOptions::default()
},
cx,
)
})
.await
... |
rust_dataset_chunk_507153 | rust_dataset.txt | 507,153 | 512 |
.update(cx, |multi_workspace, window, cx| {
multi_workspace.activate(remote_workspace.clone(), None, window, cx);
window.activate_window();
})
.unwrap();
let result = cx
.update(|cx| {
open_paths(
... |
rust_dataset_chunk_507154 | rust_dataset.txt | 507,154 | 512 | fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
let project_a = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
// A second project entity pointing at the same path produces the same key.
let project_a2 = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
let key_a = ... |
rust_dataset_chunk_507155 | rust_dataset.txt | 507,155 | 512 | assert_eq!(keys.len(), 1);
assert_eq!(keys[0], initial_key);
});
// Add a second worktree to the project. This triggers WorktreeAdded →
// handle_workspace_key_change, which should update the group key.
project
.update(cx, |project, cx| {
project.find_or_create_workt... |
rust_dataset_chunk_507156 | rust_dataset.txt | 507,156 | 512 | |mw, _cx| {
assert_eq!(
mw.workspace().entity_id(),
active_workspace_id,
"active workspace should remain unchanged after reopening the same path"
);
assert_eq!(
mw.workspaces().count(),
1,
"reusing the active workspace shou... |
rust_dataset_chunk_507157 | rust_dataset.txt | 507,157 | 512 | ().read(cx).root_paths(cx)),
project_group_key.path_list().clone(),
"the activated workspace should use the project group key path list rather than the missing linked-worktree path"
);
assert_eq!(
mw.workspaces().count(),
1,
"falling back to th... |
rust_dataset_chunk_507158 | rust_dataset.txt | 507,158 | 512 | .executor());
fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
fs.insert_tree("/root_b", json!({ "file.txt": "" })).await;
cx.update(|cx| <dyn Fs>::set_global(fs.clone(), cx));
let project_a = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
let project_b = Project::test(fs, ["/... |
rust_dataset_chunk_507159 | rust_dataset.txt | 507,159 | 512 | _until_parked();
let active_workspace = multi_workspace.read_with(cx, |mw, cx| {
assert_eq!(
mw.project_groups(cx).len(),
1,
"opening the sidebar should retain the active workspace in a project group"
);
mw.workspace().clone()
});
let active_works... |
rust_dataset_chunk_507160 | rust_dataset.txt | 507,160 | 512 | });
cx.run_until_parked();
let workspace_a = multi_workspace.read_with(cx, |multi_workspace, _cx| {
multi_workspace.workspace().clone()
});
let workspace_b = multi_workspace.update_in(cx, |multi_workspace, window, cx| {
multi_workspace.test_add_workspace(project_b, window, cx)
});
... |
rust_dataset_chunk_507161 | rust_dataset.txt | 507,161 | 512 | Context) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
fs.insert_tree("/project-a", json!({})).await;
fs.insert_tree("/project-b", json!({})).await;
let project_a_1 = Project::test(fs.clone(), ["/project-a".as_ref()], cx).await;
let project_a_2 = Project::test(fs.clone(), ["/project-a".... |
rust_dataset_chunk_507162 | rust_dataset.txt | 507,162 | 512 | cx)
.cloned()
.collect::<Vec<_>>(),
vec![workspace_a_2],
"only the fallback workspace should remain in project group A"
);
assert_eq!(multi_workspace.project_group_keys(), vec![key_b, key_a]);
});
}
#[gpui::test]
async fn test_close_workspace... |
rust_dataset_chunk_507163 | rust_dataset.txt | 507,163 | 512 | -a".as_ref()], cx).await;
let key_a = project_a.read_with(cx, |project, cx| project.project_group_key(cx));
let key_b = ProjectGroupKey::new(None, PathList::new(&[PathBuf::from("/project-b")]));
let (multi_workspace, cx) = setup_multi_workspace(&[project_a], cx);
multi_workspace.update(cx, |multi_works... |
rust_dataset_chunk_507164 | rust_dataset.txt | 507,164 | 512 | .await
.expect("removing the active project group should succeed");
assert!(
removed,
"remove_project_group should remove the active group"
);
multi_workspace.read_with(cx, |multi_workspace, cx| {
assert_eq!(
multi_workspace.workspace().read(cx).project_... |
rust_dataset_chunk_507165 | rust_dataset.txt | 507,165 | 512 | &workspace_a,
"removing the active project group should replace its provisional workspace"
);
assert!(
multi_workspace
.workspace()
.read(cx)
.root_paths(cx)
.is_empty(),
"an unloaded remote neighbor sho... |
rust_dataset_chunk_507166 | rust_dataset.txt | 507,166 | 512 | switching away with the sidebar closed"
);
}
#[gpui::test]
async fn test_remote_project_root_dir_changes_update_groups(cx: &mut TestAppContext) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
fs.insert_tree("/local_b", json!({ "file... |
rust_dataset_chunk_507167 | rust_dataset.txt | 507,167 | 512 | _string(),
root_name: "project".to_string(),
updated_entries: vec![proto::Entry {
id: 1,
is_dir: true,
path: "".to_string(),
inode: 1,
mtime: Some(proto::Timestamp {
... |
rust_dataset_chunk_507168 | rust_dataset.txt | 507,168 | 512 | arked();
let empty_workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(window.into(), cx);
// Add a dirty untitled item to the empty workspace.
let dirty_item = cx.new(|cx| TestItem::new(cx).with_dirty(true));
em... |
rust_dataset_chunk_507169 | rust_dataset.txt | 507,169 | 512 | ::new(&[path!("/project_a")])
)]
);
})
.unwrap();
assert!(
empty_workspace.read_with(cx, |workspace, _cx| workspace.session_id().is_none()),
"the detached empty workspace should no longer be attached to the session",
);
let dirty_item = cx.new(|cx... |
rust_dataset_chunk_507170 | rust_dataset.txt | 507,170 | 512 | multi_workspace.update(cx, |mw, cx| {
mw.open_sidebar(cx);
});
cx.run_until_parked();
// Add a mock-remote group with no workspace as the second group.
let remote_key = ProjectGroupKey::new(
Some(RemoteConnectionOptions::Mock(
remote::MockConnectionOptions { id: 1 },
... |
rust_dataset_chunk_507171 | rust_dataset.txt | 507,171 | 512 | ".as_ref()], cx).await;
let (multi_workspace, cx) =
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project_a.clone(), window, cx));
multi_workspace.update(cx, |mw, cx| {
mw.open_sidebar(cx);
});
cx.run_until_parked();
let key_a = project_a.read_with(cx, |p, cx| p.project... |
rust_dataset_chunk_507172 | rust_dataset.txt | 507,172 | 512 | The second
// workspace is activated after the first, making it the group's last active workspace.
let project_a_1 = Project::test(fs.clone(), ["/project-a".as_ref()], cx).await;
let project_a_2 = Project::test(fs.clone(), ["/project-a".as_ref()], cx).await;
let project_b = Project::test(fs.clone(), ["... |
rust_dataset_chunk_507173 | rust_dataset.txt | 507,173 | 512 | workspace_a_1 = retained_workspaces_a
.into_iter()
.next()
.cloned()
.expect("project group A should have a retained workspace");
let workspace_a_2 = multi_workspace
.last_active_workspace_for_group(&key_a, cx)
.expect("project group A sho... |
rust_dataset_chunk_507174 | rust_dataset.txt | 507,174 | 512 | workspace_a_2,
],
cx
),
None,
"no workspace should be returned when every candidate is excluded"
);
});
}
#[gpui::test]
async fn test_nearest_retained_workspace_skips_disconnected_workspace(cx: &mut TestAppContext) {
init_test(cx);
... |
rust_dataset_chunk_507175 | rust_dataset.txt | 507,175 | 512 | use ui::{CopyButton, Tooltip, prelude::*};
use util::ResultExt;
#[derive(Default)]
pub struct Notifications {
notifications: Vec<(NotificationId, AnyView)>,
}
impl Deref for Notifications {
type Target = Vec<(NotificationId, AnyView)>;
fn deref(&self) -> &Self::Target {
&self.notifications
}
... |
rust_dataset_chunk_507176 | rust_dataset.txt | 507,176 | 512 | >) -> Entity<V>,
) {
self.show_notification_without_handling_dismiss_events(&id, cx, |cx| {
let notification = build_notification(cx);
cx.subscribe(¬ification, {
let id = id.clone();
move |this, _, _: &DismissEvent, cx| {
this.di... |
rust_dataset_chunk_507177 | rust_dataset.txt | 507,177 | 512 | ast.message, cx).when_some(
toast.on_click,
|this, (click_msg, on_click)| {
this.primary_message(click_msg)
.primary_on_click(move |window, cx| on_click(window, cx))
},
)
})
... |
rust_dataset_chunk_507178 | rust_dataset.txt | 507,178 | 512 | .message == request.message
})
})
{
return;
}
self.show_notification(
NotificationId::composite::<LanguageServerPrompt>(request.id),
cx,
|cx| cx.new(|cx| LanguageServerPrompt::new(request.clone(), cx)),
);
}... |
rust_dataset_chunk_507179 | rust_dataset.txt | 507,179 | 512 | = None;
cx.emit(DismissEvent);
}
}
impl Render for LanguageServerPrompt {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let Some(request) = &self.request else {
return div().id("language_server_prompt_notification");
};
let... |
rust_dataset_chunk_507180 | rust_dataset.txt | 507,180 | 512 | cx.emit(SuppressEvent);
} else {
this.dismiss_notification(cx);
}
},
... |
rust_dataset_chunk_507181 | rust_dataset.txt | 507,181 | 512 | _code: TextStyleRefinement {
background_color: Some(cx.theme().colors().editor_background.opacity(0.5)),
font_family: Some(buffer_font_family),
font_fallbacks: buffer_font_fallbacks,
..Default::default()
},
link: TextStyleRefinement {
underline... |
rust_dataset_chunk_507182 | rust_dataset.txt | 507,182 | 512 | ::now());
self.task = Some(cx.spawn(async move |this, cx| {
cx.background_executor().timer(duration).await;
if let Err(error) = this.update(cx, |this, cx| {
if let Some(auto_hide) = this.auto_hide.as_mut() {
auto_hide.finish_timer()... |
rust_dataset_chunk_507183 | rust_dataset.txt | 507,183 | 512 | (started_at.elapsed(), FADE_TO_FULL_OPACITY_DURATION);
start_opacity + (1.0 - start_opacity) * progress
}
None => 1.0,
}
}
fn finish_timer(&mut self) {
self.task.take();
self.timer_started = None;
self.r... |
rust_dataset_chunk_507184 | rust_dataset.txt | 507,184 | 512 | _handle.clone()
}
}
impl EventEmitter<DismissEvent> for MessageNotification {}
impl EventEmitter<SuppressEvent> for MessageNotification {}
impl Notification for MessageNotification {}
impl FluentBuilder for MessageNotification {}
impl MessageNotification {
pub fn new<S>(messa... |
rust_dataset_chunk_507185 | rust_dataset.txt | 507,185 | 512 | _color(mut self, color: Color) -> Self {
self.primary_icon_color = Some(color);
self
}
pub fn primary_on_click<F>(mut self, on_click: F) -> Self
where
F: 'static + Fn(&mut Window, &mut Context<Self>),
{
self.primary_on_click = Some(Arc::ne... |
rust_dataset_chunk_507186 | rust_dataset.txt | 507,186 | 512 | mut Context<Self>) -> AnyElement {
let notification = cx.weak_entity();
let entries = self.secondary_menu_entries.clone();
PopoverMenu::new(("notification-secondary-menu", cx.entity_id()))
.trigger_with_tooltip(
IconButton::new(
... |
rust_dataset_chunk_507187 | rust_dataset.txt | 507,187 | 512 | = Some(color);
self
}
pub fn secondary_content<S: Into<SharedString>>(mut self, text: S) -> Self {
self.secondary_content = Some(text.into());
self
}
pub fn copy_text<S: Into<SharedString>>(mut self, text: S) -> Self {
self.copy_text = S... |
rust_dataset_chunk_507188 | rust_dataset.txt | 507,188 | 512 | handler,
} = action;
this.secondary_message(label)
.when_some(icon, |this, icon| match icon.position {
IconPosition::Start => this.secondary_icon(icon.name),
IconPosition::End => this.secondary_end_... |
rust_dataset_chunk_507189 | rust_dataset.txt | 507,189 | 512 | _flex()
.flex_shrink_0()
.gap_1()
.when_some(copy_text, |el, text| {
el.child(
CopyButton::new("copy-notification-message", text)
.tooltip_label("Copy Message"),
)
... |
rust_dataset_chunk_507190 | rust_dataset.txt | 507,190 | 512 | .on_click(cx.listener(|this, _, window, cx| {
if let Some(on_click) = this.secondary_on_click.as_ref() {
(on_click)(window, cx)
};
this.dismiss(cx)
}))
.wh... |
rust_dataset_chunk_507191 | rust_dataset.txt | 507,191 | 512 | ()
.gap_1()
.child(
div()
.child(
div()
.id("message-notification-content")
... |
rust_dataset_chunk_507192 | rust_dataset.txt | 507,192 | 512 | ::new("Some informational content for the user.", cx)
.with_title("Notification Title")
});
let with_primary_action = cx.new(|cx| {
MessageNotification::new("A new version of Zed is available for download.", cx)
.with_title("Update Availab... |
rust_dataset_chunk_507193 | rust_dataset.txt | 507,193 | 512 | (msg.clone(), cx).copy_text(msg)
});
let no_close = cx.new(|cx| {
MessageNotification::new("This notification can't be closed manually.", cx)
.show_close_button(false)
});
// --- Workspace errors ---
// These showcase comm... |
rust_dataset_chunk_507194 | rust_dataset.txt | 507,194 | 512 | AI.".into()
}
fn severity(&self) -> ErrorSeverity {
ErrorSeverity::Critical
}
fn primary_action(&self) -> ErrorAction {
ErrorAction::link("Update Zed", "https://zed.dev/releases")
}
f... |
rust_dataset_chunk_507195 | rust_dataset.txt | 507,195 | 512 | into_any_element(),
),
single_example(
"With Documentation Link",
container().child(docs_error).into_any_element(),
),
single_example(
... |
rust_dataset_chunk_507196 | rust_dataset.txt | 507,196 | 512 | id.clone();
move |workspace: &mut Workspace, _, _: &SuppressEvent, cx| {
workspace.suppress_notification(&id, cx);
}
})
.detach();
notification.into()
}
})... |
rust_dataset_chunk_507197 | rust_dataset.txt | 507,197 | 512 | fn notify_err(self, workspace: &mut Workspace, cx: &mut Context<Workspace>) -> Option<T> {
match self {
Ok(value) => Some(value),
Err(err) => {
log::error!("Showing error notification in workspace: {err:?}");
workspace.show_error(format!("Error: {err}"... |
rust_dataset_chunk_507198 | rust_dataset.txt | 507,198 | 512 | : impl FnOnce(&anyhow::Error, &mut Window, &mut App) -> Option<String> + 'static,
) -> Task<Option<R>>;
fn detach_and_prompt_err(
self,
msg: &str,
window: &Window,
cx: &App,
f: impl FnOnce(&anyhow::Error, &mut Window, &mut App) -> Option<String> + 'static,
);
}
impl... |
rust_dataset_chunk_507199 | rust_dataset.txt | 507,199 | 512 | );
let fs = FakeFs::new(cx.executor());
let project = Project::test(fs, [], cx).await;
let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
let count_notifications = |workspace: &Entity<Workspace>, cx: &mut TestAppContext... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.