From 504b16944bff5d4036a39566dabe9d10a0b6ea36 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:57:07 +0100 Subject: [PATCH] Clean up editor_benchmarks build Co-authored-by: Smit Barmase --- crates/editor_benchmarks/src/main.rs | 79 +++++++++++++++------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/crates/editor_benchmarks/src/main.rs b/crates/editor_benchmarks/src/main.rs index 52bf9137fd8419b9137eaf4d970ea9acf881a961..bdd3f1c6beb7e880986ff253a97a78a2d3bfde62 100644 --- a/crates/editor_benchmarks/src/main.rs +++ b/crates/editor_benchmarks/src/main.rs @@ -1,9 +1,7 @@ use std::sync::Arc; use editor::Editor; -use gpui::{ - AppContext as _, AsyncApp, AsyncWindowContext, WeakEntity, WindowBounds, WindowOptions, -}; +use gpui::{AppContext as _, AsyncWindowContext, WeakEntity, WindowBounds, WindowOptions}; use language::Buffer; use multi_buffer::Anchor; use project::search::SearchQuery; @@ -135,42 +133,47 @@ fn main() { ) .expect("failed to open window"); - window_handle.update(cx, move |this, window, cx| { - cx.spawn_in( - window, - async move |weak: WeakEntity, cx: &mut AsyncWindowContext| { - let find_task = weak.update_in(cx, |editor, window, cx| { - editor.find_matches(query.clone(), window, cx) - })?; - - println!("Finding matches..."); - let timer = std::time::Instant::now(); - let matches: Vec> = find_task.await; - let find_elapsed = timer.elapsed(); - println!("Found {} matches in {find_elapsed:?}", matches.len()); - - if has_replacement && !matches.is_empty() { - window_handle.update(cx, |editor: &mut Editor, window, cx| { - let mut match_iter = matches.iter(); - println!("Replacing all matches..."); - let timer = std::time::Instant::now(); - editor.replace_all( - &mut match_iter, - &query, - Default::default(), - window, - cx, - ); - let replace_elapsed = timer.elapsed(); - println!("Replaced {} matches in {replace_elapsed:?}", matches.len()); + window_handle + .update(cx, move |_, window, cx| { + cx.spawn_in( + window, + async move |weak: WeakEntity, cx: &mut AsyncWindowContext| { + let find_task = weak.update_in(cx, |editor, window, cx| { + editor.find_matches(query.clone(), window, cx) })?; - } - cx.update(|_, cx: &mut gpui::App| cx.quit()); - anyhow::Ok(()) - }, - ) - .detach(); - }); + println!("Finding matches..."); + let timer = std::time::Instant::now(); + let matches: Vec> = find_task.await; + let find_elapsed = timer.elapsed(); + println!("Found {} matches in {find_elapsed:?}", matches.len()); + + if has_replacement && !matches.is_empty() { + window_handle.update(cx, |editor: &mut Editor, window, cx| { + let mut match_iter = matches.iter(); + println!("Replacing all matches..."); + let timer = std::time::Instant::now(); + editor.replace_all( + &mut match_iter, + &query, + Default::default(), + window, + cx, + ); + let replace_elapsed = timer.elapsed(); + println!( + "Replaced {} matches in {replace_elapsed:?}", + matches.len() + ); + })?; + } + + std::process::exit(0); + anyhow::Ok(()) + }, + ) + .detach(); + }) + .unwrap(); }); }