fixed matching order so that shelf matches before files in current dir

This commit is contained in:
2026-08-21 16:34:34 +01:00
parent 9c0d92d07c
commit 3a223aa084

View File

@@ -90,8 +90,7 @@ pub fn match_file_name(file_name: &str, shelf: &mut Shelf) -> Result<usize, std:
// Turn given file into string
let match_path = Path::new(file_name);
// If the file path doesnt exist
if !match_path.exists() {
// Check if there is a match in the shelf before taking the path verbatim
let file_ending = match_path.file_name().expect("Error getting file name");
// For every entry in current shelf
for (i, path) in shelf.content.iter().enumerate() {
@@ -102,8 +101,8 @@ pub fn match_file_name(file_name: &str, shelf: &mut Shelf) -> Result<usize, std:
return Ok(i);
};
}
} // else if it does
if match_path.exists() {
let cannonical_path = match_path.canonicalize()?;
for (i, path) in shelf.content.iter().enumerate() {
@@ -112,6 +111,7 @@ pub fn match_file_name(file_name: &str, shelf: &mut Shelf) -> Result<usize, std:
return Ok(i);
}
}
}
Err(io::Error::new(
io::ErrorKind::NotFound,