Don't refcount window handles

This commit is contained in:
Nathan Sobo 2023-08-03 17:11:47 -06:00
parent afcc0d621b
commit 485c0a482e
20 changed files with 83 additions and 163 deletions

View File

@ -3446,7 +3446,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
let editor_a = window_a.add_view(cx_a, |cx| Editor::for_buffer(buffer_a, Some(project_a), cx));
let mut editor_cx_a = EditorTestContext {
cx: cx_a,
window_id: window_a.id(),
window_id: window_a.window_id(),
editor: editor_a,
};
@ -3459,7 +3459,7 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
let editor_b = window_b.add_view(cx_b, |cx| Editor::for_buffer(buffer_b, Some(project_b), cx));
let mut editor_cx_b = EditorTestContext {
cx: cx_b,
window_id: window_b.id(),
window_id: window_b.window_id(),
editor: editor_b,
};

View File

@ -49,7 +49,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|_| IncomingCallNotification::new(incoming_call.clone(), app_state.clone()),
);
notification_windows.push(window.id());
notification_windows.push(window.window_id());
}
}
}

View File

@ -52,7 +52,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
notification_windows
.entry(*project_id)
.or_insert(Vec::new())
.push(window.id());
.push(window.window_id());
}
}
room::Event::RemoteProjectUnshared { project_id } => {

View File

@ -297,7 +297,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), [], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let editor = cx.add_view(window_id, |cx| {
let mut editor = Editor::single_line(None, cx);
editor.set_text("abc", cx);

View File

@ -25,7 +25,7 @@ pub fn init(cx: &mut AppContext) {
match &status {
crate::Status::SigningIn { prompt } => {
if let Some(code_verification_handle) = code_verification.as_mut() {
let window_id = code_verification_handle.id();
let window_id = code_verification_handle.window_id();
let updated = cx.update_window(window_id, |cx| {
code_verification_handle.update_root(cx, |code_verification, cx| {
code_verification.set_status(status.clone(), cx)
@ -41,7 +41,7 @@ pub fn init(cx: &mut AppContext) {
}
Status::Authorized | Status::Unauthorized => {
if let Some(code_verification) = code_verification.as_ref() {
let window_id = code_verification.id();
let window_id = code_verification.window_id();
cx.update_window(window_id, |cx| {
code_verification.update_root(cx, |code_verification, cx| {
code_verification.set_status(status, cx)

View File

@ -857,7 +857,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
// Create some diagnostics
project.update(cx, |project, cx| {
@ -1252,7 +1252,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let view = cx.add_view(window_id, |cx| {
ProjectDiagnosticsEditor::new(project.clone(), workspace.downgrade(), cx)

View File

@ -525,7 +525,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
let project = Project::test(fs, [], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
cx.add_view(window_id, |cx| {
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);

View File

@ -99,7 +99,7 @@ impl<'a> EditorLspTestContext<'a> {
Self {
cx: EditorTestContext {
cx,
window_id: window.id(),
window_id: window.window_id(),
editor,
},
lsp,

View File

@ -39,7 +39,7 @@ impl<'a> EditorTestContext<'a> {
let editor = window.root(cx);
Self {
cx,
window_id: window.id(),
window_id: window.window_id(),
editor,
}
}

View File

@ -619,7 +619,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
cx.dispatch_action(window.id(), Toggle);
cx.dispatch_action(window.window_id(), Toggle);
let finder = cx.read(|cx| workspace.read(cx).modal::<FileFinder>().unwrap());
finder
@ -632,8 +632,8 @@ mod tests {
});
let active_pane = cx.read(|cx| workspace.read(cx).active_pane().clone());
cx.dispatch_action(window.id(), SelectNext);
cx.dispatch_action(window.id(), Confirm);
cx.dispatch_action(window.window_id(), SelectNext);
cx.dispatch_action(window.window_id(), Confirm);
active_pane
.condition(cx, |pane, _| pane.active_item().is_some())
.await;
@ -674,7 +674,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/src".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
cx.dispatch_action(window.id(), Toggle);
cx.dispatch_action(window.window_id(), Toggle);
let finder = cx.read(|cx| workspace.read(cx).modal::<FileFinder>().unwrap());
let file_query = &first_file_name[..3];
@ -706,8 +706,8 @@ mod tests {
});
let active_pane = cx.read(|cx| workspace.read(cx).active_pane().clone());
cx.dispatch_action(window.id(), SelectNext);
cx.dispatch_action(window.id(), Confirm);
cx.dispatch_action(window.window_id(), SelectNext);
cx.dispatch_action(window.window_id(), Confirm);
active_pane
.condition(cx, |pane, _| pane.active_item().is_some())
.await;
@ -758,7 +758,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/src".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
cx.dispatch_action(window.id(), Toggle);
cx.dispatch_action(window.window_id(), Toggle);
let finder = cx.read(|cx| workspace.read(cx).modal::<FileFinder>().unwrap());
let file_query = &first_file_name[..3];
@ -790,8 +790,8 @@ mod tests {
});
let active_pane = cx.read(|cx| workspace.read(cx).active_pane().clone());
cx.dispatch_action(window.id(), SelectNext);
cx.dispatch_action(window.id(), Confirm);
cx.dispatch_action(window.window_id(), SelectNext);
cx.dispatch_action(window.window_id(), Confirm);
active_pane
.condition(cx, |pane, _| pane.active_item().is_some())
.await;
@ -1168,7 +1168,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/src".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let worktree_id = cx.read(|cx| {
let worktrees = workspace.read(cx).worktrees(cx).collect::<Vec<_>>();
assert_eq!(worktrees.len(), 1);
@ -1376,7 +1376,7 @@ mod tests {
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let worktree_id = cx.read(|cx| {
let worktrees = workspace.read(cx).worktrees(cx).collect::<Vec<_>>();
assert_eq!(worktrees.len(), 1,);

View File

@ -1337,7 +1337,7 @@ impl AppContext {
.open_window(window_id, window_options, this.foreground.clone());
let window = this.build_window(window_id, platform_window, build_root_view);
this.windows.insert(window_id, window);
WindowHandle::new(window_id, this.ref_counts.clone())
WindowHandle::new(window_id)
})
}
@ -3863,21 +3863,21 @@ impl<T> Clone for WeakModelHandle<T> {
impl<T> Copy for WeakModelHandle<T> {}
pub struct WindowHandle<T> {
any_handle: AnyWindowHandle,
view_type: PhantomData<T>,
window_id: usize,
root_view_type: PhantomData<T>,
}
#[allow(dead_code)]
impl<V: View> WindowHandle<V> {
fn new(window_id: usize, ref_counts: Arc<Mutex<RefCounts>>) -> Self {
fn new(window_id: usize) -> Self {
WindowHandle {
any_handle: AnyWindowHandle::new::<V>(window_id, ref_counts),
view_type: PhantomData,
window_id,
root_view_type: PhantomData,
}
}
pub fn id(&self) -> usize {
self.any_handle.id()
pub fn window_id(&self) -> usize {
self.window_id
}
pub fn root<C: BorrowWindowContext>(&self, cx: &C) -> C::Result<ViewHandle<V>> {
@ -3889,7 +3889,7 @@ impl<V: View> WindowHandle<V> {
C: BorrowWindowContext,
F: FnOnce(&WindowContext) -> R,
{
cx.read_window_with(self.id(), |cx| read(cx))
cx.read_window_with(self.window_id(), |cx| read(cx))
}
pub fn update<C, F, R>(&self, cx: &mut C, update: F) -> R
@ -3897,7 +3897,7 @@ impl<V: View> WindowHandle<V> {
C: BorrowAppContext,
F: FnOnce(&mut WindowContext) -> R,
{
cx.update(|cx| cx.update_window(self.id(), update).unwrap())
cx.update(|cx| cx.update_window(self.window_id(), update).unwrap())
}
pub fn update_root<C, F, R>(&self, cx: &mut C, update: F) -> R
@ -3905,7 +3905,7 @@ impl<V: View> WindowHandle<V> {
C: BorrowAppContext,
F: FnOnce(&mut V, &mut ViewContext<V>) -> R,
{
let window_id = self.id();
let window_id = self.window_id();
cx.update(|cx| {
cx.update_window(window_id, |cx| {
cx.root_view()
@ -3920,7 +3920,9 @@ impl<V: View> WindowHandle<V> {
pub fn read_root<'a>(&self, cx: &'a AppContext) -> &'a V {
let root_view = cx
.read_window(self.id(), |cx| cx.root_view().clone().downcast().unwrap())
.read_window(self.window_id(), |cx| {
cx.root_view().clone().downcast().unwrap()
})
.unwrap();
root_view.read(cx)
}
@ -3948,66 +3950,6 @@ impl<V: View> WindowHandle<V> {
}
}
pub struct AnyWindowHandle {
window_id: usize,
root_view_type: TypeId,
ref_counts: Option<Arc<Mutex<RefCounts>>>,
#[cfg(any(test, feature = "test-support"))]
handle_id: usize,
}
impl AnyWindowHandle {
fn new<V: View>(window_id: usize, ref_counts: Arc<Mutex<RefCounts>>) -> Self {
ref_counts.lock().inc_window(window_id);
#[cfg(any(test, feature = "test-support"))]
let handle_id = ref_counts
.lock()
.leak_detector
.lock()
.handle_created(None, window_id);
Self {
window_id,
root_view_type: TypeId::of::<V>(),
ref_counts: Some(ref_counts),
#[cfg(any(test, feature = "test-support"))]
handle_id,
}
}
pub fn id(&self) -> usize {
self.window_id
}
pub fn downcast<V: View>(self) -> Option<WindowHandle<V>> {
if TypeId::of::<V>() == self.root_view_type {
Some(WindowHandle {
any_handle: self,
view_type: PhantomData,
})
} else {
None
}
}
}
impl Drop for AnyWindowHandle {
fn drop(&mut self) {
if let Some(ref_counts) = self.ref_counts.as_ref() {
ref_counts.lock().dec_window(self.window_id);
#[cfg(any(test, feature = "test-support"))]
ref_counts
.lock()
.leak_detector
.lock()
.handle_dropped(self.window_id, self.handle_id);
}
}
}
#[repr(transparent)]
pub struct ViewHandle<T> {
any_handle: AnyViewHandle,
@ -6281,7 +6223,7 @@ mod tests {
// Check that global actions do not have a binding, even if a binding does exist in another view
assert_eq!(
&available_actions(window.id(), view_1.id(), cx),
&available_actions(window.window_id(), view_1.id(), cx),
&[
("test::Action1", vec![Keystroke::parse("a").unwrap()]),
("test::GlobalAction", vec![])
@ -6290,7 +6232,7 @@ mod tests {
// Check that view 1 actions and bindings are available even when called from view 2
assert_eq!(
&available_actions(window.id(), view_2.id(), cx),
&available_actions(window.window_id(), view_2.id(), cx),
&[
("test::Action1", vec![Keystroke::parse("a").unwrap()]),
("test::Action2", vec![Keystroke::parse("b").unwrap()]),
@ -6353,7 +6295,7 @@ mod tests {
]);
});
let actions = cx.available_actions(window.id(), view.id());
let actions = cx.available_actions(window.window_id(), view.id());
assert_eq!(
actions[0].1.as_any().downcast_ref::<ActionWithArg>(),
Some(&ActionWithArg { arg: false })
@ -6639,25 +6581,25 @@ mod tests {
[("window 2", false), ("window 3", true)]
);
cx.simulate_window_activation(Some(window_2.id()));
cx.simulate_window_activation(Some(window_2.window_id()));
assert_eq!(
mem::take(&mut *events.borrow_mut()),
[("window 3", false), ("window 2", true)]
);
cx.simulate_window_activation(Some(window_1.id()));
cx.simulate_window_activation(Some(window_1.window_id()));
assert_eq!(
mem::take(&mut *events.borrow_mut()),
[("window 2", false), ("window 1", true)]
);
cx.simulate_window_activation(Some(window_3.id()));
cx.simulate_window_activation(Some(window_3.window_id()));
assert_eq!(
mem::take(&mut *events.borrow_mut()),
[("window 1", false), ("window 3", true)]
);
cx.simulate_window_activation(Some(window_3.id()));
cx.simulate_window_activation(Some(window_3.window_id()));
assert_eq!(mem::take(&mut *events.borrow_mut()), []);
}

View File

@ -25,7 +25,6 @@ struct ElementStateRefCount {
pub struct RefCounts {
entity_counts: HashMap<usize, usize>,
element_state_counts: HashMap<ElementStateId, ElementStateRefCount>,
dropped_windows: HashSet<usize>,
dropped_models: HashSet<usize>,
dropped_views: HashSet<(usize, usize)>,
dropped_element_states: HashSet<ElementStateId>,
@ -44,18 +43,6 @@ impl RefCounts {
}
}
pub fn inc_window(&mut self, window_id: usize) {
match self.entity_counts.entry(window_id) {
Entry::Occupied(mut entry) => {
*entry.get_mut() += 1;
}
Entry::Vacant(entry) => {
entry.insert(1);
self.dropped_windows.remove(&window_id);
}
}
}
pub fn inc_model(&mut self, model_id: usize) {
match self.entity_counts.entry(model_id) {
Entry::Occupied(mut entry) => {
@ -98,15 +85,6 @@ impl RefCounts {
}
}
pub fn dec_window(&mut self, window_id: usize) {
let count = self.entity_counts.get_mut(&window_id).unwrap();
*count -= 1;
if *count == 0 {
self.entity_counts.remove(&window_id);
self.dropped_windows.insert(window_id);
}
}
pub fn dec_model(&mut self, model_id: usize) {
let count = self.entity_counts.get_mut(&model_id).unwrap();
*count -= 1;

View File

@ -157,9 +157,9 @@ impl TestAppContext {
.cx
.borrow_mut()
.add_window(Default::default(), build_root_view);
self.simulate_window_activation(Some(window.id()));
self.simulate_window_activation(Some(window.window_id()));
WindowHandle::new(window.id(), self.cx.borrow_mut().ref_counts.clone())
WindowHandle::new(window.window_id())
}
pub fn add_view<T, F>(&mut self, window_id: usize, build_view: F) -> ViewHandle<T>

View File

@ -1165,7 +1165,7 @@ impl<'a> WindowContext<'a> {
let root_view = self.add_view(|cx| build_root_view(cx));
self.window.focused_view_id = Some(root_view.id());
self.window.root_view = Some(root_view.into_any());
WindowHandle::new(self.window_id, self.ref_counts.clone())
WindowHandle::new(self.window_id)
}
pub fn add_view<T, F>(&mut self, build_view: F) -> ViewHandle<T>

View File

@ -1872,7 +1872,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let panel = workspace.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx));
select_path(&panel, "root1", cx);
@ -2225,7 +2225,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let panel = workspace.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx));
select_path(&panel, "root1", cx);
@ -2402,7 +2402,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/src".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let panel = workspace.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx));
toggle_expand_dir(&panel, "src/test", cx);
@ -2493,7 +2493,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/src".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let panel = workspace.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx));
select_path(&panel, "src/", cx);

View File

@ -328,7 +328,7 @@ mod tests {
let window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
// Create the project symbols view.
let symbols = cx.add_view(window_id, |cx| {

View File

@ -851,11 +851,11 @@ mod tests {
});
let window = cx.add_window(|_| EmptyView);
let editor = cx.add_view(window.id(), |cx| {
let editor = cx.add_view(window.window_id(), |cx| {
Editor::for_buffer(buffer.clone(), None, cx)
});
let search_bar = cx.add_view(window.id(), |cx| {
let search_bar = cx.add_view(window.window_id(), |cx| {
let mut search_bar = BufferSearchBar::new(cx);
search_bar.set_active_pane_item(Some(&editor), cx);
search_bar.show(cx);
@ -1232,7 +1232,7 @@ mod tests {
);
let buffer = cx.add_model(|cx| Buffer::new(0, buffer_text, cx));
let window = cx.add_window(|_| EmptyView);
let window_id = window.id();
let window_id = window.window_id();
let editor = cx.add_view(window_id, |cx| Editor::for_buffer(buffer.clone(), None, cx));
@ -1421,11 +1421,11 @@ mod tests {
let buffer = cx.add_model(|cx| Buffer::new(0, buffer_text, cx));
let window = cx.add_window(|_| EmptyView);
let editor = cx.add_view(window.id(), |cx| {
let editor = cx.add_view(window.window_id(), |cx| {
Editor::for_buffer(buffer.clone(), None, cx)
});
let search_bar = cx.add_view(window.id(), |cx| {
let search_bar = cx.add_view(window.window_id(), |cx| {
let mut search_bar = BufferSearchBar::new(cx);
search_bar.set_active_pane_item(Some(&editor), cx);
search_bar.show(cx);

View File

@ -1568,7 +1568,7 @@ pub mod tests {
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let active_item = cx.read(|cx| {
workspace
@ -1874,7 +1874,7 @@ pub mod tests {
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
workspace.update(cx, |workspace, cx| {
ProjectSearchView::deploy(workspace, &workspace::NewSearch, cx)
});

View File

@ -4196,14 +4196,14 @@ mod tests {
);
});
assert_eq!(
cx.current_window_title(window.id()).as_deref(),
cx.current_window_title(window.window_id()).as_deref(),
Some("one.txt — root1")
);
// Add a second item to a non-empty pane
workspace.update(cx, |workspace, cx| workspace.add_item(Box::new(item2), cx));
assert_eq!(
cx.current_window_title(window.id()).as_deref(),
cx.current_window_title(window.window_id()).as_deref(),
Some("two.txt — root1")
);
project.read_with(cx, |project, cx| {
@ -4222,7 +4222,7 @@ mod tests {
.await
.unwrap();
assert_eq!(
cx.current_window_title(window.id()).as_deref(),
cx.current_window_title(window.window_id()).as_deref(),
Some("one.txt — root1")
);
project.read_with(cx, |project, cx| {
@ -4242,14 +4242,14 @@ mod tests {
.await
.unwrap();
assert_eq!(
cx.current_window_title(window.id()).as_deref(),
cx.current_window_title(window.window_id()).as_deref(),
Some("one.txt — root1, root2")
);
// Remove a project folder
project.update(cx, |project, cx| project.remove_worktree(worktree_id, cx));
assert_eq!(
cx.current_window_title(window.id()).as_deref(),
cx.current_window_title(window.window_id()).as_deref(),
Some("one.txt — root2")
);
}
@ -4285,9 +4285,9 @@ mod tests {
});
let task = workspace.update(cx, |w, cx| w.prepare_to_close(false, cx));
cx.foreground().run_until_parked();
cx.simulate_prompt_answer(window.id(), 2 /* cancel */);
cx.simulate_prompt_answer(window.window_id(), 2 /* cancel */);
cx.foreground().run_until_parked();
assert!(!cx.has_pending_prompt(window.id()));
assert!(!cx.has_pending_prompt(window.window_id()));
assert!(!task.await.unwrap());
}
@ -4346,10 +4346,10 @@ mod tests {
assert_eq!(pane.items_len(), 4);
assert_eq!(pane.active_item().unwrap().id(), item1.id());
});
assert!(cx.has_pending_prompt(window.id()));
assert!(cx.has_pending_prompt(window.window_id()));
// Confirm saving item 1.
cx.simulate_prompt_answer(window.id(), 0);
cx.simulate_prompt_answer(window.window_id(), 0);
cx.foreground().run_until_parked();
// Item 1 is saved. There's a prompt to save item 3.
@ -4360,10 +4360,10 @@ mod tests {
assert_eq!(pane.items_len(), 3);
assert_eq!(pane.active_item().unwrap().id(), item3.id());
});
assert!(cx.has_pending_prompt(window.id()));
assert!(cx.has_pending_prompt(window.window_id()));
// Cancel saving item 3.
cx.simulate_prompt_answer(window.id(), 1);
cx.simulate_prompt_answer(window.window_id(), 1);
cx.foreground().run_until_parked();
// Item 3 is reloaded. There's a prompt to save item 4.
@ -4374,10 +4374,10 @@ mod tests {
assert_eq!(pane.items_len(), 2);
assert_eq!(pane.active_item().unwrap().id(), item4.id());
});
assert!(cx.has_pending_prompt(window.id()));
assert!(cx.has_pending_prompt(window.window_id()));
// Confirm saving item 4.
cx.simulate_prompt_answer(window.id(), 0);
cx.simulate_prompt_answer(window.window_id(), 0);
cx.foreground().run_until_parked();
// There's a prompt for a path for item 4.
@ -4480,7 +4480,7 @@ mod tests {
&[ProjectEntryId::from_proto(0)]
);
});
cx.simulate_prompt_answer(window.id(), 0);
cx.simulate_prompt_answer(window.window_id(), 0);
cx.foreground().run_until_parked();
left_pane.read_with(cx, |pane, cx| {
@ -4489,7 +4489,7 @@ mod tests {
&[ProjectEntryId::from_proto(2)]
);
});
cx.simulate_prompt_answer(window.id(), 0);
cx.simulate_prompt_answer(window.window_id(), 0);
cx.foreground().run_until_parked();
close.await.unwrap();
@ -4549,7 +4549,7 @@ mod tests {
item.read_with(cx, |item, _| assert_eq!(item.save_count, 2));
// Deactivating the window still saves the file.
cx.simulate_window_activation(Some(window.id()));
cx.simulate_window_activation(Some(window.window_id()));
item.update(cx, |item, cx| {
cx.focus_self();
item.is_dirty = true;
@ -4591,7 +4591,7 @@ mod tests {
pane.update(cx, |pane, cx| pane.close_items(cx, move |id| id == item_id))
.await
.unwrap();
assert!(!cx.has_pending_prompt(window.id()));
assert!(!cx.has_pending_prompt(window.window_id()));
item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));
// Add the item again, ensuring autosave is prevented if the underlying file has been deleted.
@ -4612,7 +4612,7 @@ mod tests {
let _close_items =
pane.update(cx, |pane, cx| pane.close_items(cx, move |id| id == item_id));
deterministic.run_until_parked();
assert!(cx.has_pending_prompt(window.id()));
assert!(cx.has_pending_prompt(window.window_id()));
item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));
}

View File

@ -1299,7 +1299,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
// Open a file within an existing worktree.
workspace
@ -1342,7 +1342,7 @@ mod tests {
project.update(cx, |project, _| project.languages().add(rust_lang()));
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let worktree = cx.read(|cx| workspace.read(cx).worktrees(cx).next().unwrap());
// Create a new untitled buffer
@ -1437,7 +1437,7 @@ mod tests {
project.update(cx, |project, _| project.languages().add(rust_lang()));
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
// Create a new untitled buffer
cx.dispatch_action(window_id, NewFile);
@ -1490,7 +1490,7 @@ mod tests {
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.root(cx);
let window_id = window.id();
let window_id = window.window_id();
let entries = cx.read(|cx| workspace.file_project_paths(cx));
let file1 = entries[0].clone();
@ -2088,7 +2088,7 @@ mod tests {
cx.foreground().run_until_parked();
let window = cx.add_window(|_| TestView);
let window_id = window.id();
let window_id = window.window_id();
// Test loading the keymap base at all
assert_key_bindings_for(
@ -2259,7 +2259,7 @@ mod tests {
cx.foreground().run_until_parked();
let window = cx.add_window(|_| TestView);
let window_id = window.id();
let window_id = window.window_id();
// Test loading the keymap base at all
assert_key_bindings_for(