file_finder: Fix highlighting panic in open path prompt (#41808)

Closes https://github.com/zed-industries/zed/issues/41249

Couldn't quite come up with a test case here but verified it works.

Release Notes:

- Fixed a panic in file finder when deleting characters
This commit is contained in:
Lukas Wirth
2025-11-03 12:07:13 +00:00
committed by GitHub
parent b625263989
commit 50504793e6
+3 -3
View File
@@ -711,7 +711,9 @@ impl PickerDelegate for OpenPathDelegate {
match &self.directory_state {
DirectoryState::List { parent_path, .. } => {
let (label, indices) = if *parent_path == self.prompt_root {
let (label, indices) = if is_current_dir_candidate {
("open this directory".to_string(), vec![])
} else if *parent_path == self.prompt_root {
match_positions.iter_mut().for_each(|position| {
*position += self.prompt_root.len();
});
@@ -719,8 +721,6 @@ impl PickerDelegate for OpenPathDelegate {
format!("{}{}", self.prompt_root, candidate.path.string),
match_positions,
)
} else if is_current_dir_candidate {
("open this directory".to_string(), vec![])
} else {
(candidate.path.string, match_positions)
};