chore: update gpui

This commit is contained in:
2025-03-25 20:53:22 +07:00
parent 4c9533bfe4
commit 42d6328d82
28 changed files with 255 additions and 211 deletions

View File

@@ -115,9 +115,8 @@ impl Element for Clipboard {
*copied.borrow_mut() = true;
let copied = copied.clone();
cx.spawn(|cx| async move {
cx.spawn(async move |cx| {
cx.background_executor().timer(Duration::from_secs(2)).await;
*copied.borrow_mut() = false;
})
.detach();

View File

@@ -574,8 +574,8 @@ impl DockArea {
window,
move |_, _, event, window, cx| {
if let PanelEvent::LayoutChanged = event {
cx.spawn_in(window, |view, mut window| async move {
_ = view.update_in(&mut window, |view, window, cx| {
cx.spawn_in(window, async move |view, window| {
_ = view.update_in(window, |view, window, cx| {
view.update_toggle_button_tab_panels(window, cx)
});
})
@@ -609,8 +609,8 @@ impl DockArea {
move |_, panel, event, window, cx| match event {
PanelEvent::ZoomIn => {
let panel = panel.clone();
cx.spawn_in(window, |view, mut window| async move {
_ = view.update_in(&mut window, |view, window, cx| {
cx.spawn_in(window, async move |view, window| {
_ = view.update_in(window, |view, window, cx| {
view.set_zoomed_in(panel, window, cx);
cx.notify();
});
@@ -618,15 +618,15 @@ impl DockArea {
.detach();
}
PanelEvent::ZoomOut => cx
.spawn_in(window, |view, mut window| async move {
_ = view.update_in(&mut window, |view, window, cx| {
.spawn_in(window, async move |view, window| {
_ = view.update_in(window, |view, window, cx| {
view.set_zoomed_out(window, cx);
});
})
.detach(),
PanelEvent::LayoutChanged => {
cx.spawn_in(window, |view, mut window| async move {
_ = view.update_in(&mut window, |view, window, cx| {
cx.spawn_in(window, async move |view, window| {
_ = view.update_in(window, |view, window, cx| {
view.update_toggle_button_tab_panels(window, cx)
});
})

View File

@@ -181,7 +181,7 @@ impl TabPanel {
self.focus_active_panel(window, cx);
// Sync the active state to all panels
cx.spawn(|view, cx| async move {
cx.spawn(async move |view, cx| {
_ = cx.update(|cx| {
_ = view.update(cx, |view, cx| {
if let Some(last_active) = view.panels.get(last_active_ix) {
@@ -255,7 +255,7 @@ impl TabPanel {
window: &mut Window,
cx: &mut Context<Self>,
) {
cx.spawn_in(window, |view, mut cx| async move {
cx.spawn_in(window, async move |view, cx| {
cx.update(|window, cx| {
view.update(cx, |view, cx| {
view.will_split_placement = Some(placement);
@@ -986,7 +986,7 @@ impl TabPanel {
});
}
cx.spawn_in(window, |_, mut cx| async move {
cx.spawn_in(window, async move |_, cx| {
cx.update(|window, cx| {
tab_panel.update(cx, |view, cx| view.remove_self_if_empty(window, cx))
})
@@ -1021,9 +1021,9 @@ impl TabPanel {
self.is_zoomed = !self.is_zoomed;
cx.spawn(|view, cx| {
cx.spawn({
let is_zoomed = self.is_zoomed;
async move {
async move |view, cx| {
_ = cx.update(|cx| {
_ = view.update(cx, |view, cx| {
view.set_zoomed(is_zoomed, cx);

View File

@@ -50,10 +50,10 @@ impl BlinkCursor {
// Schedule the next blink
let epoch = self.next_epoch();
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
Timer::after(INTERVAL).await;
if let Some(this) = this.upgrade() {
this.update(&mut cx, |this, cx| this.blink(epoch, cx)).ok();
this.update(cx, |this, cx| this.blink(epoch, cx)).ok();
}
})
.detach();
@@ -71,11 +71,11 @@ impl BlinkCursor {
// delay 500ms to start the blinking
let epoch = self.next_epoch();
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
Timer::after(PAUSE_DELAY).await;
if let Some(this) = this.upgrade() {
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.paused = false;
this.blink(epoch, cx);
})

View File

@@ -266,10 +266,10 @@ where
self.set_loading(true, window, cx);
let search = self.delegate.perform_search(&text, window, cx);
self._search_task = cx.spawn_in(window, |this, mut window| async move {
self._search_task = cx.spawn_in(window, async move |this, window| {
search.await;
_ = this.update_in(&mut window, |this, _, _| {
_ = this.update_in(window, |this, _, _| {
this.vertical_scroll_handle
.scroll_to_item(0, ScrollStrategy::Top);
this.last_query = Some(text);
@@ -277,7 +277,7 @@ where
// Always wait 100ms to avoid flicker
Timer::after(Duration::from_millis(100)).await;
_ = this.update_in(&mut window, |this, window, cx| {
_ = this.update_in(window, |this, window, cx| {
this.set_loading(false, window, cx);
});
});

View File

@@ -193,7 +193,7 @@ impl Notification {
cx.notify();
// Dismiss the notification after 0.15s to show the animation.
cx.spawn(|view, cx| async move {
cx.spawn(async move |view, cx| {
Timer::after(Duration::from_secs_f32(0.15)).await;
cx.update(|cx| {
if let Some(view) = view.upgrade() {
@@ -339,9 +339,9 @@ impl NotificationList {
self.notifications.push_back(notification.clone());
if autohide {
// Sleep for 3 seconds to autohide the notification
cx.spawn_in(window, |_, mut cx| async move {
cx.spawn_in(window, async move |_, cx| {
Timer::after(Duration::from_secs(3)).await;
_ = notification.update_in(&mut cx, |note, window, cx| {
_ = notification.update_in(cx, |note, window, cx| {
note.dismiss(&ClickEvent::default(), window, cx)
});
})

View File

@@ -164,9 +164,8 @@ impl Element for Switch {
.map_or(false, |prev| prev != checked)
{
let dur = Duration::from_secs_f64(0.15);
cx.spawn(|cx| async move {
cx.spawn(async move |cx| {
cx.background_executor().timer(dur).await;
*prev_checked.borrow_mut() = Some(checked);
})
.detach();