From 5f40904129c522a346d55f3617c47df6660fdd78 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:55:13 -0400 Subject: [PATCH] feat: preserve more settings across loads --- src/app.rs | 9 +++++++-- src/app/data.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 6c886f0..e259eb0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -310,12 +310,17 @@ impl LogViewerApp { match Data::try_from((self.row_idx_field_name.as_ref(), &data[..])) { Ok(mut data) => { if let Some(old_data) = self.data.as_mut() { - // Preserve filter settings across loads of the data - data.filter = old_data.filter.take(); + // Preserve settings across loads of the data + data.take_config( + old_data, + self.data_display_options.common_fields(), + ); } self.data = Some(data); if self.should_scroll_to_end_on_load { self.move_selected_last(); + } else { + self.should_scroll = true; } LoadingStatus::NotInProgress } diff --git a/src/app/data.rs b/src/app/data.rs index c1e4ca8..50f629a 100644 --- a/src/app/data.rs +++ b/src/app/data.rs @@ -246,6 +246,19 @@ impl Data { warn!("Apply called but no filter is available") } } + + pub fn take_config(&mut self, other: &mut Self, common_fields: &BTreeSet) { + let is_filtered = other.is_filtered(); + self.filter = other.filter.take(); + if is_filtered { + self.apply_filter(common_fields); + } + if let Some(i) = other.selected_row { + if i < self.len() { + self.selected_row = Some(i); + } + } + } } fn is_included(