diff options
-rw-r--r-- | src/history.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/history.rs b/src/history.rs index 0f604c3..7c6076f 100644 --- a/src/history.rs +++ b/src/history.rs @@ -26,26 +26,24 @@ impl DirectoryHistory for JoshutoHistory { let mut ancestors = pathbuf.ancestors(); match ancestors.next() { None => {} - Some(mut ancestor) => { - for curr in ancestors { - match JoshutoDirList::new(curr.to_path_buf().clone(), sort_option) { - Ok(mut s) => { - let index = s.contents.iter().enumerate().find_map(|(i, dir)| { - if dir.path == ancestor { - Some(i) - } else { - None - } - }); - if let Some(i) = index { - s.index = Some(i); + Some(mut ancestor) => for curr in ancestors { + match JoshutoDirList::new(curr.to_path_buf().clone(), sort_option) { + Ok(mut s) => { + let index = s.contents.iter().enumerate().find_map(|(i, dir)| { + if dir.path == ancestor { + Some(i) + } else { + None } - self.insert(curr.to_path_buf(), s); + }); + if let Some(i) = index { + s.index = Some(i); } - Err(e) => eprintln!("populate_to_root: {}", e), + self.insert(curr.to_path_buf(), s); } - ancestor = curr; + Err(e) => eprintln!("populate_to_root: {}", e), } + ancestor = curr; } } } |