From 1be8f2c307f9c3ba401a969f8b5b715230df5c6a Mon Sep 17 00:00:00 2001 From: sxyazi Date: Wed, 13 Mar 2024 23:46:25 +0800 Subject: [PATCH] .. --- yazi-core/src/manager/commands/tab_close.rs | 2 +- yazi-core/src/manager/manager.rs | 2 ++ yazi-core/src/tab/tab.rs | 8 ++++++++ yazi-fm/src/app/commands/quit.rs | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/manager/commands/tab_close.rs b/yazi-core/src/manager/commands/tab_close.rs index 7ae538fb..01a23672 100644 --- a/yazi-core/src/manager/commands/tab_close.rs +++ b/yazi-core/src/manager/commands/tab_close.rs @@ -25,7 +25,7 @@ impl Tabs { return; } - self.items.remove(opt.idx); + self.items.remove(opt.idx).shutdown(); if opt.idx <= self.idx { self.set_idx(self.absolute(1)); } diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/manager/manager.rs index a6bf8f2e..b1fea58c 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/manager/manager.rs @@ -23,6 +23,8 @@ impl Manager { mimetype: Default::default(), } } + + pub fn shutdown(&mut self) { self.tabs.iter_mut().for_each(|t| t.shutdown()); } } impl Manager { diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index 0a36c1f4..f8ccf62e 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -48,6 +48,14 @@ impl From<&Url> for Tab { fn from(url: &Url) -> Self { Self::from(url.clone()) } } +impl Tab { + pub fn shutdown(&mut self) { + if let Some(handle) = self.search.take() { + handle.abort(); + } + } +} + impl Tab { // --- Current pub fn selected_or_hovered(&self) -> Vec<&Url> { diff --git a/yazi-fm/src/app/commands/quit.rs b/yazi-fm/src/app/commands/quit.rs index ccecf0dc..e3d2ac18 100644 --- a/yazi-fm/src/app/commands/quit.rs +++ b/yazi-fm/src/app/commands/quit.rs @@ -8,6 +8,7 @@ use crate::app::App; impl App { pub(crate) fn quit(&mut self, opt: EventQuit) -> ! { self.cx.tasks.shutdown(); + self.cx.manager.shutdown(); if !opt.no_cwd_file { self.cwd_to_file();