mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Always finish previous autosave before starting a new one
This commit is contained in:
parent
ebf4bae173
commit
a5c39acf4c
2 changed files with 8 additions and 10 deletions
|
@ -5591,11 +5591,11 @@ impl Editor {
|
||||||
let (cancel_tx, mut cancel_rx) = oneshot::channel();
|
let (cancel_tx, mut cancel_rx) = oneshot::channel();
|
||||||
self.cancel_pending_autosave = Some(cancel_tx);
|
self.cancel_pending_autosave = Some(cancel_tx);
|
||||||
self.pending_autosave = Some(cx.spawn_weak(|this, mut cx| async move {
|
self.pending_autosave = Some(cx.spawn_weak(|this, mut cx| async move {
|
||||||
let mut timer = futures::future::join(
|
let mut timer = cx
|
||||||
cx.background().timer(Duration::from_millis(milliseconds)),
|
.background()
|
||||||
pending_autosave,
|
.timer(Duration::from_millis(milliseconds))
|
||||||
)
|
|
||||||
.fuse();
|
.fuse();
|
||||||
|
pending_autosave.await;
|
||||||
futures::select! {
|
futures::select! {
|
||||||
_ = timer => {}
|
_ = timer => {}
|
||||||
_ = cancel_rx => return None,
|
_ = cancel_rx => return None,
|
||||||
|
@ -6634,8 +6634,8 @@ mod tests {
|
||||||
editor.read(cx).selections.ranges(cx)
|
editor.read(cx).selections.ranges(cx)
|
||||||
);
|
);
|
||||||
assert_set_eq!(
|
assert_set_eq!(
|
||||||
cloned_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| dbg!(e.selections.display_ranges(cx)))
|
editor.update(cx, |e, cx| e.selections.display_ranges(cx))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue