always check if a search is active when rescanning (#712)
This commit is contained in:
parent
199632580c
commit
59ea01fc0c
1 changed files with 29 additions and 25 deletions
54
src/app.rs
54
src/app.rs
|
|
@ -773,7 +773,7 @@ impl App {
|
|||
Task::batch([
|
||||
self.update_title(),
|
||||
self.update_watcher(),
|
||||
self.rescan_tab(entity, location, selection_paths),
|
||||
self.update_tab(entity, location, selection_paths),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
|
@ -829,7 +829,20 @@ impl App {
|
|||
return Task::none();
|
||||
}
|
||||
}
|
||||
self.rescan_tab(entity, tab.location.clone(), Some(op_sel.selected))
|
||||
self.update_tab(entity, tab.location.clone(), Some(op_sel.selected))
|
||||
}
|
||||
|
||||
fn update_tab(
|
||||
&mut self,
|
||||
entity: Entity,
|
||||
location: Location,
|
||||
selection_paths: Option<Vec<PathBuf>>,
|
||||
) -> Task<Message> {
|
||||
if let Location::Search(_, term, ..) = location {
|
||||
self.search_set(entity, Some(term), selection_paths)
|
||||
} else {
|
||||
self.rescan_tab(entity, location, selection_paths)
|
||||
}
|
||||
}
|
||||
|
||||
fn rescan_tab(
|
||||
|
|
@ -873,19 +886,11 @@ impl App {
|
|||
|
||||
let mut commands = Vec::with_capacity(needs_reload.len());
|
||||
for (entity, location) in needs_reload {
|
||||
commands.push(self.rescan_tab(entity, location, None));
|
||||
commands.push(self.update_tab(entity, location, None));
|
||||
}
|
||||
Task::batch(commands)
|
||||
}
|
||||
|
||||
fn search(&mut self) -> Task<Message> {
|
||||
if let Some(term) = self.search_get() {
|
||||
self.search_set_active(Some(term.to_string()))
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
||||
fn search_get(&self) -> Option<&str> {
|
||||
let entity = self.tab_model.active();
|
||||
let tab = self.tab_model.data::<Tab>(entity)?;
|
||||
|
|
@ -897,10 +902,15 @@ impl App {
|
|||
|
||||
fn search_set_active(&mut self, term_opt: Option<String>) -> Task<Message> {
|
||||
let entity = self.tab_model.active();
|
||||
self.search_set(entity, term_opt)
|
||||
self.search_set(entity, term_opt, None)
|
||||
}
|
||||
|
||||
fn search_set(&mut self, tab: Entity, term_opt: Option<String>) -> Task<Message> {
|
||||
fn search_set(
|
||||
&mut self,
|
||||
tab: Entity,
|
||||
term_opt: Option<String>,
|
||||
selection_paths: Option<Vec<PathBuf>>,
|
||||
) -> Task<Message> {
|
||||
let mut title_location_opt = None;
|
||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(tab) {
|
||||
let location_opt = match term_opt {
|
||||
|
|
@ -931,7 +941,7 @@ impl App {
|
|||
return Task::batch([
|
||||
self.update_title(),
|
||||
self.update_watcher(),
|
||||
self.rescan_tab(tab, location, None),
|
||||
self.rescan_tab(tab, location, selection_paths),
|
||||
if focus_search {
|
||||
widget::text_input::focus(self.search_id.clone())
|
||||
} else {
|
||||
|
|
@ -990,7 +1000,7 @@ impl App {
|
|||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
||||
tab.location = location.clone();
|
||||
}
|
||||
commands.push(self.rescan_tab(entity, location, None));
|
||||
commands.push(self.update_tab(entity, location, None));
|
||||
}
|
||||
Task::batch(commands)
|
||||
}
|
||||
|
|
@ -2139,7 +2149,7 @@ impl Application for App {
|
|||
};
|
||||
if let Some(title) = title_opt {
|
||||
self.tab_model.text_set(entity, title);
|
||||
commands.push(self.rescan_tab(entity, home_location.clone(), None));
|
||||
commands.push(self.update_tab(entity, home_location.clone(), None));
|
||||
}
|
||||
}
|
||||
if !commands.is_empty() {
|
||||
|
|
@ -2304,11 +2314,7 @@ impl Application for App {
|
|||
|
||||
let mut commands = Vec::with_capacity(needs_reload.len());
|
||||
for (entity, location) in needs_reload {
|
||||
if let Location::Search(_, term, ..) = location {
|
||||
commands.push(self.search_set(entity, Some(term)));
|
||||
} else {
|
||||
commands.push(self.rescan_tab(entity, location, None));
|
||||
}
|
||||
commands.push(self.update_tab(entity, location, None));
|
||||
}
|
||||
return Task::batch(commands);
|
||||
}
|
||||
|
|
@ -2547,8 +2553,6 @@ impl Application for App {
|
|||
commands.push(self.rescan_operation_selection(op_sel));
|
||||
// Manually rescan any trash tabs after any operation is completed
|
||||
commands.push(self.rescan_trash());
|
||||
// if search is active, update "search" tab view
|
||||
commands.push(self.search());
|
||||
return Task::batch(commands);
|
||||
}
|
||||
Message::PendingDismiss => {
|
||||
|
|
@ -2871,7 +2875,7 @@ impl Application for App {
|
|||
commands.push(Task::batch([
|
||||
self.update_title(),
|
||||
self.update_watcher(),
|
||||
self.rescan_tab(entity, tab_path, selection_paths),
|
||||
self.update_tab(entity, tab_path, selection_paths),
|
||||
]));
|
||||
}
|
||||
tab::Command::DropFiles(to, from) => {
|
||||
|
|
@ -3164,7 +3168,7 @@ impl Application for App {
|
|||
return Task::batch([
|
||||
self.update_title(),
|
||||
self.update_watcher(),
|
||||
self.rescan_tab(entity, location, None),
|
||||
self.update_tab(entity, location, None),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue