fix some iteration bugs
This commit is contained in:
parent
de51666742
commit
8eab2502c7
8 changed files with 143 additions and 89 deletions
|
|
@ -182,7 +182,9 @@ impl App {
|
|||
|
||||
for file in fs::read_dir(logs_dir)? {
|
||||
let file = file?;
|
||||
files.push(file);
|
||||
if file.path().extension().is_some_and(|ext| ext == "log") {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(files)
|
||||
|
|
@ -207,6 +209,23 @@ impl App {
|
|||
self.tabs.last_mut().unwrap()
|
||||
}
|
||||
|
||||
fn start_log_viewer(&mut self, path: PathBuf) {
|
||||
let filters_path = path.with_added_extension("filters.json");
|
||||
match LogfileReader::new(&path) {
|
||||
Ok(i) => {
|
||||
self.current_file = Some(i.clone());
|
||||
self.replace_tab(Tab::LogViewer(LogViewer::new(
|
||||
i.iter(),
|
||||
filters_path,
|
||||
self.last_error.clone(),
|
||||
)));
|
||||
}
|
||||
Err(_) => {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_current_tab_keycode(&mut self, key: KeyEvent) {
|
||||
match self.tabs.last_mut().unwrap() {
|
||||
Tab::Help => {}
|
||||
|
|
@ -227,15 +246,8 @@ impl App {
|
|||
if let Some(selected) = state.selected()
|
||||
&& let Some(selected) = files.get(selected)
|
||||
{
|
||||
match LogfileReader::new(&selected.path()) {
|
||||
Ok(i) => {
|
||||
self.current_file = Some(i.clone());
|
||||
self.replace_tab(Tab::LogViewer(LogViewer::new(i.iter())));
|
||||
}
|
||||
Err(_) => {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
let path = selected.path();
|
||||
self.start_log_viewer(path);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -452,17 +464,8 @@ impl App {
|
|||
if state.selected() == Some(row)
|
||||
&& let Some(selected) = files.get(row)
|
||||
{
|
||||
match LogfileReader::new(&selected.path()) {
|
||||
Ok(i) => {
|
||||
self.current_file = Some(i.clone());
|
||||
self.replace_tab(Tab::LogViewer(LogViewer::new(
|
||||
i.iter(),
|
||||
)));
|
||||
}
|
||||
Err(_) => {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
let path = selected.path();
|
||||
self.start_log_viewer(path);
|
||||
} else {
|
||||
state.select(Some(row));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue