From a5c39acf4c9cf1bc3277d9e10c15a9970b8fce25 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 5 Jul 2022 17:36:40 +0200 Subject: [PATCH] Always finish previous autosave before starting a new one --- crates/editor/src/editor.rs | 14 +++++++------- crates/gpui/src/executor.rs | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1f4b75e7cb..f6d62a3c83 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5591,11 +5591,11 @@ impl Editor { let (cancel_tx, mut cancel_rx) = oneshot::channel(); self.cancel_pending_autosave = Some(cancel_tx); self.pending_autosave = Some(cx.spawn_weak(|this, mut cx| async move { - let mut timer = futures::future::join( - cx.background().timer(Duration::from_millis(milliseconds)), - pending_autosave, - ) - .fuse(); + let mut timer = cx + .background() + .timer(Duration::from_millis(milliseconds)) + .fuse(); + pending_autosave.await; futures::select! { _ = timer => {} _ = cancel_rx => return None, @@ -6634,8 +6634,8 @@ mod tests { editor.read(cx).selections.ranges(cx) ); assert_set_eq!( - cloned_editor.update(cx, |e, cx| dbg!(e.selections.display_ranges(cx))), - editor.update(cx, |e, cx| dbg!(e.selections.display_ranges(cx))) + cloned_editor.update(cx, |e, cx| e.selections.display_ranges(cx)), + editor.update(cx, |e, cx| e.selections.display_ranges(cx)) ); } diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 6ed00c238f..7c2ba44c44 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -675,9 +675,7 @@ impl Background { } } _ => { - log::info!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - - // panic!("this method can only be called on a deterministic executor") + panic!("this method can only be called on a deterministic executor") } } }