bugfixing and testing
This commit is contained in:
parent
e490a2ce04
commit
d0bc7e952c
5 changed files with 411 additions and 109 deletions
|
|
@ -7,7 +7,7 @@ use crate::tui::{
|
|||
input::{FieldMatcher, InputState, InputTarget},
|
||||
view::LogView,
|
||||
},
|
||||
model::LogEntry,
|
||||
model::{LogEntry, id},
|
||||
processing::Cursor,
|
||||
widgets::last_error::LastError,
|
||||
};
|
||||
|
|
@ -19,7 +19,7 @@ pub mod input;
|
|||
pub mod view;
|
||||
|
||||
pub struct LogViewer {
|
||||
cache: HashMap<Vec<usize>, LogView>,
|
||||
cache: HashMap<usize, usize>,
|
||||
|
||||
pub view: LogView,
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ pub struct LogViewer {
|
|||
|
||||
impl LogViewer {
|
||||
pub fn new(start: Gc<LogEntry>, filters_path: PathBuf, error: LastError) -> Self {
|
||||
let filters = Filters::new(filters_path, error);
|
||||
let filters = Filters::new(Some(filters_path), error);
|
||||
Self {
|
||||
view: LogView {
|
||||
cursor: Cursor::new(start),
|
||||
|
|
@ -200,8 +200,29 @@ impl LogViewer {
|
|||
}
|
||||
}
|
||||
|
||||
fn update_offset_from_cache(&mut self) {
|
||||
let cache_key = self.view.cursor.parent().as_ref().map(id).unwrap_or(0);
|
||||
|
||||
self.view.selection_offset = 0;
|
||||
if let Some(offset) = self.cache.get(&cache_key) {
|
||||
for _ in 0..*offset {
|
||||
self.view.selection_offset += 1;
|
||||
self.view.cursor.prev(&self.filters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_to_cache(&mut self) {
|
||||
let cache_key = self.view.cursor.parent().as_ref().map(id).unwrap_or(0);
|
||||
self.cache.insert(cache_key, self.view.selection_offset);
|
||||
}
|
||||
|
||||
pub fn back(&mut self) {
|
||||
self.view.cursor.exit(&self.filters);
|
||||
self.add_to_cache();
|
||||
if self.view.cursor.exit(&self.filters) {
|
||||
self.update_offset_from_cache();
|
||||
self.view.cursor.prev(&self.filters);
|
||||
}
|
||||
// self.cache.insert(self.path(), self.curr.clone());
|
||||
self.input_state.reset();
|
||||
}
|
||||
|
|
@ -217,38 +238,18 @@ impl LogViewer {
|
|||
pub fn enter(&mut self) {
|
||||
match self.input_state {
|
||||
InputState::None => {
|
||||
self.add_to_cache();
|
||||
|
||||
let orig = self.view.cursor.clone();
|
||||
for _ in 0..(self.view.selection_offset + 1) {
|
||||
self.view.cursor.next(&self.filters);
|
||||
}
|
||||
|
||||
self.view.cursor.enter(&self.filters);
|
||||
// let Some((s, _)) = self.selected() else {
|
||||
// return;
|
||||
// };
|
||||
// let Some(i) = s.from_start(0).map(|i| i.with_filters(self.filters.get())) else {
|
||||
// return;
|
||||
// };
|
||||
//
|
||||
// if i.clone().next(self.filters.get()).is_none() {
|
||||
// return;
|
||||
// }
|
||||
// if i.clone()
|
||||
// .next(self.filters.get())
|
||||
// .is_some_and(|(i, _)| i.is_return())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// self.stack.push(mem::replace(
|
||||
// &mut self.curr,
|
||||
// LogView {
|
||||
// cursor: i,
|
||||
// selection_offset: 0,
|
||||
// },
|
||||
// ));
|
||||
// if let Some(cached_view) = self.cache.get(&self.path()) {
|
||||
// self.curr = cached_view.clone();
|
||||
// }
|
||||
if self.view.cursor.enter(&self.filters) {
|
||||
self.update_offset_from_cache();
|
||||
} else {
|
||||
self.view.cursor = orig;
|
||||
}
|
||||
}
|
||||
InputState::Target(InputTarget::Fields(None)) => {
|
||||
self.input_state =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue