@@ -18,21 +18,13 @@ use crate::tracedecay::TraceDecay;
1818
1919use super :: super :: ToolResult ;
2020use super :: super :: render:: { self , Md } ;
21- use super :: support:: unique_file_paths;
21+ use super :: support:: { CancelSearchOnDrop , unique_file_paths} ;
2222
2323/// Hard cap on `max_results` regardless of what the caller requests.
2424const MAX_RESULTS_CAP : usize = 200 ;
2525/// Default `max_results` when the caller omits it.
2626const DEFAULT_MAX_RESULTS : usize = 50 ;
2727
28- struct CancelSearchOnDrop ( Arc < AtomicBool > ) ;
29-
30- impl Drop for CancelSearchOnDrop {
31- fn drop ( & mut self ) {
32- self . 0 . store ( true , Ordering :: Release ) ;
33- }
34- }
35-
3628async fn search_tree_off_thread (
3729 project_root : std:: path:: PathBuf ,
3830 pattern : String ,
@@ -43,7 +35,7 @@ async fn search_tree_off_thread(
4335) -> Result < crate :: ast_grep_search:: AstGrepSearchResult > {
4436 let query = pattern. clone ( ) ;
4537 let cancelled = Arc :: new ( AtomicBool :: new ( false ) ) ;
46- let cancel_on_drop = CancelSearchOnDrop ( cancelled. clone ( ) ) ;
38+ let cancel_on_drop = CancelSearchOnDrop :: new ( cancelled. clone ( ) ) ;
4739 let result = tokio:: task:: spawn_blocking ( move || {
4840 search_tree_scoped_with_cancel (
4941 & project_root,
@@ -224,7 +216,7 @@ mod tests {
224216 fn cancellation_guard_signals_worker_on_drop ( ) {
225217 let cancelled = std:: sync:: Arc :: new ( std:: sync:: atomic:: AtomicBool :: new ( false ) ) ;
226218 {
227- let _guard = CancelSearchOnDrop ( cancelled. clone ( ) ) ;
219+ let _guard = CancelSearchOnDrop :: new ( cancelled. clone ( ) ) ;
228220 }
229221 assert ! ( cancelled. load( std:: sync:: atomic:: Ordering :: Acquire ) ) ;
230222 }
0 commit comments