Fix panic in completions menu (#3778)

We were shifting all the positions while keeping the original string,
which caused problems later when combining highlighted ranges with
matched indices.

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra
2023-12-22 12:27:52 +01:00
committed by GitHub
+4 -4
View File
@@ -1350,15 +1350,15 @@ impl CompletionsMenu {
completion.sort_key(), completion.sort_key(),
) )
}); });
drop(completions);
for mat in &mut matches { for mat in &mut matches {
let completions = self.completions.read(); let completion = &completions[mat.candidate_id];
let filter_start = completions[mat.candidate_id].label.filter_range.start; mat.string = completion.label.text.clone();
for position in &mut mat.positions { for position in &mut mat.positions {
*position += filter_start; *position += completion.label.filter_range.start;
} }
} }
drop(completions);
self.matches = matches.into(); self.matches = matches.into();
self.selected_item = 0; self.selected_item = 0;