Avoid excessive diagnostics refreshes (#21173)
Attempts to reduce the diagnostics flicker, when editing very fundamental parts of the large code base in Rust. https://github.com/user-attachments/assets/dc3f9c21-8c6e-48db-967b-040649fd00da Release Notes: - N/A
This commit is contained in:
parent
28142be5e9
commit
bd02b35ba9
3 changed files with 28 additions and 6 deletions
|
@ -538,12 +538,15 @@ impl<T: 'static> Model<T> {
|
|||
|
||||
impl<V: 'static> View<V> {
|
||||
/// Returns a future that resolves when the view is next updated.
|
||||
pub fn next_notification(&self, cx: &TestAppContext) -> impl Future<Output = ()> {
|
||||
pub fn next_notification(
|
||||
&self,
|
||||
advance_clock_by: Duration,
|
||||
cx: &TestAppContext,
|
||||
) -> impl Future<Output = ()> {
|
||||
use postage::prelude::{Sink as _, Stream as _};
|
||||
|
||||
let (mut tx, mut rx) = postage::mpsc::channel(1);
|
||||
let mut cx = cx.app.app.borrow_mut();
|
||||
let subscription = cx.observe(self, move |_, _| {
|
||||
let subscription = cx.app.app.borrow_mut().observe(self, move |_, _| {
|
||||
tx.try_send(()).ok();
|
||||
});
|
||||
|
||||
|
@ -553,6 +556,8 @@ impl<V: 'static> View<V> {
|
|||
Duration::from_secs(1)
|
||||
};
|
||||
|
||||
cx.executor().advance_clock(advance_clock_by);
|
||||
|
||||
async move {
|
||||
let notification = crate::util::timeout(duration, rx.recv())
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue