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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user