From 9c1f58ee89b5a171100aebdbab6a7736848aed85 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 14 Jan 2022 09:12:30 +0100 Subject: [PATCH] Maintain order of outline items when filling out tree's missing parts --- crates/language/src/outline.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/language/src/outline.rs b/crates/language/src/outline.rs index e6a5258f9c..dc1a8e3aef 100644 --- a/crates/language/src/outline.rs +++ b/crates/language/src/outline.rs @@ -67,6 +67,7 @@ impl Outline { *position = name_range.start as usize + (*position - preceding_ranges_len); } + let insertion_ix = tree_matches.len(); let mut cur_depth = outline_match.depth; for (ix, item) in self.items[prev_item_ix..string_match.candidate_index] .iter() @@ -79,12 +80,15 @@ impl Outline { let candidate_index = ix + prev_item_ix; if item.depth == cur_depth - 1 { - tree_matches.push(StringMatch { - candidate_index, - score: Default::default(), - positions: Default::default(), - string: Default::default(), - }); + tree_matches.insert( + insertion_ix, + StringMatch { + candidate_index, + score: Default::default(), + positions: Default::default(), + string: Default::default(), + }, + ); cur_depth -= 1; } }