From 21797bad4d939af85b10fba9f615b07cd4cb5f5f Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 5 Feb 2024 13:26:42 -0500 Subject: [PATCH] file_finder: Simplify removal of file name from file path (#7398) This PR simplifies the removal of the file name from the file path when computing the file finder matches. Release Notes: - N/A --- crates/file_finder/src/file_finder.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index d222682e80..521682e6b3 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -584,12 +584,7 @@ impl FileFinderDelegate { }) .collect(); - // Trim file name from the full path - let full_path = if full_path.len() > file_name.len() { - full_path[..full_path.len() - file_name.len() - 1].to_string() - } else { - "".to_string() - }; + let full_path = full_path.trim_end_matches(&file_name).to_string(); path_positions.retain(|idx| *idx < full_path.len()); (file_name, file_name_positions, full_path, path_positions)