@@ -3148,12 +3148,13 @@ mod tests {
});
fs::remove_file(dir.path().join("file2")).unwrap();
- tree.flush_fs_events(&app).await;
+ buffer2
+ .condition(&app, |buffer2, _| buffer2.is_dirty())
+ .await;
assert_eq!(
*events.borrow(),
&[Event::Dirtied, Event::FileHandleChanged]
);
- app.read(|ctx| assert!(buffer2.read(ctx).is_dirty()));
// When a file is already dirty when deleted, we don't emit a Dirtied event.
let events = Rc::new(RefCell::new(Vec::new()));
@@ -3173,7 +3174,9 @@ mod tests {
});
events.borrow_mut().clear();
fs::remove_file(dir.path().join("file3")).unwrap();
- tree.flush_fs_events(&app).await;
+ buffer3
+ .condition(&app, |_, _| !events.borrow().is_empty())
+ .await;
assert_eq!(*events.borrow(), &[Event::FileHandleChanged]);
app.read(|ctx| assert!(buffer3.read(ctx).is_dirty()));
});
@@ -3222,7 +3225,6 @@ mod tests {
});
let new_contents = "AAAA\naaa\nBB\nbbbbb\n";
fs::write(&abs_path, new_contents).unwrap();
- tree.flush_fs_events(&app).await;
// Because the buffer was not modified, it is reloaded from disk. Its
// contents are edited according to the diff between the old and new
@@ -1030,20 +1030,17 @@ mod tests {
app.update(|ctx| editor.update(ctx, |editor, ctx| editor.insert(&"x".to_string(), ctx)));
fs::write(dir.path().join("a.txt"), "changed").unwrap();
- tree.flush_fs_events(&app).await;
- app.read(|ctx| {
- assert!(editor.is_dirty(ctx));
- assert!(editor.has_conflict(ctx));
- });
+ editor
+ .condition(&app, |editor, ctx| editor.has_conflict(ctx))
+ .await;
+ app.read(|ctx| assert!(editor.is_dirty(ctx)));
app.update(|ctx| workspace.update(ctx, |w, ctx| w.save_active_item(&(), ctx)));
app.simulate_prompt_answer(window_id, 0);
- tree.update(&mut app, |tree, ctx| tree.next_scan_complete(ctx))
+ editor
+ .condition(&app, |editor, ctx| !editor.is_dirty(ctx))
.await;
- app.read(|ctx| {
- assert!(!editor.is_dirty(ctx));
- assert!(!editor.has_conflict(ctx));
- });
+ app.read(|ctx| assert!(!editor.has_conflict(ctx)));
}
#[gpui::test]
@@ -1097,7 +1094,8 @@ mod tests {
});
// When the save completes, the buffer's title is updated.
- tree.update(&mut app, |tree, ctx| tree.next_scan_complete(ctx))
+ editor
+ .condition(&app, |editor, ctx| !editor.is_dirty(ctx))
.await;
app.read(|ctx| {
assert!(!editor.is_dirty(ctx));
@@ -134,20 +134,6 @@ impl Worktree {
}
}
- pub fn next_scan_complete(&self, ctx: &mut ModelContext<Self>) -> impl Future<Output = ()> {
- let scan_id = self.snapshot.scan_id;
- let mut scan_state = self.scan_state.1.clone();
- ctx.spawn(|this, ctx| async move {
- while let Some(scan_state) = scan_state.recv().await {
- if this.read_with(&ctx, |this, _| {
- matches!(scan_state, ScanState::Idle) && this.snapshot.scan_id > scan_id
- }) {
- break;
- }
- }
- })
- }
-
fn observe_scan_state(&mut self, scan_state: ScanState, ctx: &mut ModelContext<Self>) {
let _ = self.scan_state.0.blocking_send(scan_state);
self.poll_entries(ctx);