Maintain order of outline items when filling out tree's missing parts

This commit is contained in:
Antonio Scandurra 2022-01-14 09:12:30 +01:00
parent adeb7e6864
commit 9c1f58ee89

View file

@ -67,6 +67,7 @@ impl<T> Outline<T> {
*position = name_range.start as usize + (*position - preceding_ranges_len); *position = name_range.start as usize + (*position - preceding_ranges_len);
} }
let insertion_ix = tree_matches.len();
let mut cur_depth = outline_match.depth; let mut cur_depth = outline_match.depth;
for (ix, item) in self.items[prev_item_ix..string_match.candidate_index] for (ix, item) in self.items[prev_item_ix..string_match.candidate_index]
.iter() .iter()
@ -79,12 +80,15 @@ impl<T> Outline<T> {
let candidate_index = ix + prev_item_ix; let candidate_index = ix + prev_item_ix;
if item.depth == cur_depth - 1 { if item.depth == cur_depth - 1 {
tree_matches.push(StringMatch { tree_matches.insert(
insertion_ix,
StringMatch {
candidate_index, candidate_index,
score: Default::default(), score: Default::default(),
positions: Default::default(), positions: Default::default(),
string: Default::default(), string: Default::default(),
}); },
);
cur_depth -= 1; cur_depth -= 1;
} }
} }