summaryrefslogtreecommitdiffstats
path: root/src/history.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-05-29 23:06:38 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-05-29 23:07:27 -0400
commit5980d762dba38b003dbe54506cdd58ee85f97c8c (patch)
tree28e07e112586b73e1de426f7ae34c8c2afc68fdb /src/history.rs
parent5d8525a9cc8a61e8e66a92f66132ad11ce112ff7 (diff)
move hostname and username out of Context and into a static global
Diffstat (limited to 'src/history.rs')
-rw-r--r--src/history.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/history.rs b/src/history.rs
index 7c6076f..0f604c3 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -26,24 +26,26 @@ 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
+ 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);
}
- });
- if let Some(i) = index {
- s.index = Some(i);
+ self.insert(curr.to_path_buf(), s);
}
- self.insert(curr.to_path_buf(), s);
+ Err(e) => eprintln!("populate_to_root: {}", e),
}
- Err(e) => eprintln!("populate_to_root: {}", e),
+ ancestor = curr;
}
- ancestor = curr;
}
}
}