fix
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use std::rc::Rc;
|
||||
use instant::Duration;
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
div, px, relative, rems, svg, Animation, AnimationExt, AnyElement, App, Div, ElementId,
|
||||
InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString,
|
||||
StatefulInteractiveElement, StyleRefinement, Styled, Window,
|
||||
Animation, AnimationExt, AnyElement, App, Div, ElementId, InteractiveElement, IntoElement,
|
||||
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, StyleRefinement, Styled,
|
||||
Window, div, px, relative, rems, svg,
|
||||
};
|
||||
use instant::Duration;
|
||||
use theme::ActiveTheme;
|
||||
|
||||
use crate::icon::IconNamed;
|
||||
use crate::{v_flex, Disableable, IconName, Selectable, Sizable, Size, StyledExt as _};
|
||||
use crate::{Disableable, IconName, Selectable, Sizable, Size, StyledExt as _, v_flex};
|
||||
|
||||
/// A Checkbox element.
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -172,10 +172,16 @@ pub(crate) fn checkbox_check_icon(
|
||||
if !disabled && checked != *toggle_state.read(cx) {
|
||||
let duration = Duration::from_secs_f64(0.25);
|
||||
cx.spawn({
|
||||
let toggle_state = toggle_state.clone();
|
||||
let toggle_state = toggle_state.downgrade();
|
||||
async move |cx| {
|
||||
cx.background_executor().timer(duration).await;
|
||||
toggle_state.update(cx, |this, _| *this = checked);
|
||||
// `update_in` (rather than `update`) routes through a
|
||||
// try-borrow: on wasm a task poll that lands while
|
||||
// the app context is borrowed can't panic and kill
|
||||
// this task.
|
||||
toggle_state
|
||||
.update_in(cx, |this, _window, _| *this = checked)
|
||||
.ok();
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use instant::Duration;
|
||||
|
||||
use gpui::{Context, Pixels, Task, px};
|
||||
use instant::Duration;
|
||||
|
||||
static INTERVAL: Duration = Duration::from_millis(500);
|
||||
static PAUSE_DELAY: Duration = Duration::from_millis(300);
|
||||
@@ -63,9 +62,11 @@ impl BlinkCursor {
|
||||
let epoch = self.next_epoch();
|
||||
self._task = cx.spawn(async move |this, cx| {
|
||||
cx.background_executor().timer(INTERVAL).await;
|
||||
if let Some(this) = this.upgrade() {
|
||||
this.update(cx, |this, cx| this.blink(epoch, cx));
|
||||
}
|
||||
// `update_in` (rather than `update`) routes through a try-borrow:
|
||||
// on wasm a task poll that lands while the app context is
|
||||
// borrowed can't panic and kill this recurring task.
|
||||
this.update_in(cx, |this, _window, cx| this.blink(epoch, cx))
|
||||
.ok();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,12 +86,11 @@ impl BlinkCursor {
|
||||
self._task = cx.spawn(async move |this, cx| {
|
||||
cx.background_executor().timer(PAUSE_DELAY).await;
|
||||
|
||||
if let Some(this) = this.upgrade() {
|
||||
this.update(cx, |this, cx| {
|
||||
this.paused = false;
|
||||
this.blink(epoch, cx);
|
||||
});
|
||||
}
|
||||
this.update_in(cx, |this, _window, cx| {
|
||||
this.paused = false;
|
||||
this.blink(epoch, cx);
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user