file_finder: Fix open path prompt creating wrong highlight indices (#40488)

Fixes ZED-28R

Release Notes:

- Fixed open path prompt panicking on certain inputs
This commit is contained in:
Lukas Wirth
2025-10-17 12:41:09 +00:00
committed by GitHub
parent b59a3bbd49
commit b7112320bb
3 changed files with 39 additions and 33 deletions
@@ -15,9 +15,16 @@ impl HighlightedLabel {
/// Constructs a label with the given characters highlighted.
/// Characters are identified by UTF-8 byte position.
pub fn new(label: impl Into<SharedString>, highlight_indices: Vec<usize>) -> Self {
let label = label.into();
for &run in &highlight_indices {
assert!(
label.is_char_boundary(run),
"highlight index {run} is not a valid UTF-8 boundary"
);
}
Self {
base: LabelLike::new(),
label: label.into(),
label,
highlight_indices,
}
}