rmptuia761500
fix #6
+11 −5
1 file changed
- M src/browser.rs +11 −5
| @@ -66,13 +66,17 @@ impl FileBrowser { | |||
| 66 | 66 | dir_vec.sort_by(|a, b| { | |
| 67 | 67 | let num_a = a.1.parse::<u32>().unwrap_or(u32::MAX); | |
| 68 | 68 | let num_b = b.1.parse::<u32>().unwrap_or(u32::MAX); | |
| 69 | − | num_a.cmp(&num_b).then_with(|| a.1.to_lowercase().cmp(&b.1.to_lowercase())) | |
| 69 | + | num_a | |
| 70 | + | .cmp(&num_b) | |
| 71 | + | .then_with(|| a.1.to_lowercase().cmp(&b.1.to_lowercase())) | |
| 70 | 72 | }); | |
| 71 | 73 | ||
| 72 | 74 | file_vec.sort_by(|a, b| { | |
| 73 | 75 | let num_a = a.1.parse::<u32>().unwrap_or(u32::MAX); | |
| 74 | 76 | let num_b = b.1.parse::<u32>().unwrap_or(u32::MAX); | |
| 75 | − | num_a.cmp(&num_b).then_with(|| a.1.to_lowercase().cmp(&b.1.to_lowercase())) | |
| 77 | + | num_a | |
| 78 | + | .cmp(&num_b) | |
| 79 | + | .then_with(|| a.1.to_lowercase().cmp(&b.1.to_lowercase())) | |
| 76 | 80 | }); | |
| 77 | 81 | ||
| 78 | 82 | dir_vec.extend(file_vec); | |
| @@ -128,9 +132,11 @@ impl FileBrowser { | |||
| 128 | 132 | /// handles going back event | |
| 129 | 133 | pub fn handle_go_back(&mut self, conn: &mut Connection) -> AppResult<()> { | |
| 130 | 134 | if self.prev_path != "." { | |
| 131 | − | let r = self.path.rfind('/').unwrap(); | |
| 132 | − | self.path = self.path.as_str()[..r].to_string(); | |
| 133 | − | self.update_directory(conn)?; | |
| 135 | + | let r = self.path.rfind('/'); | |
| 136 | + | if let Some(r) = r { | |
| 137 | + | self.path = self.path.as_str()[..r].to_string(); | |
| 138 | + | self.update_directory(conn)?; | |
| 139 | + | } | |
| 134 | 140 | } else { | |
| 135 | 141 | self.path = self.prev_path.clone(); | |
| 136 | 142 | self.update_directory(conn)?; | |