mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Use OutlineItem::depth
to include ancestors of matching candidates
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
aee3bb98f2
commit
e165f1e16c
1 changed files with 9 additions and 4 deletions
|
@ -55,24 +55,29 @@ impl Outline {
|
||||||
*position += outline_match.name_range_in_text.start;
|
*position += outline_match.name_range_in_text.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
.rev()
|
||||||
{
|
{
|
||||||
|
if cur_depth == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let candidate_index = ix + prev_item_ix;
|
let candidate_index = ix + prev_item_ix;
|
||||||
if item.range.contains(&outline_match.range.start)
|
if item.depth == cur_depth - 1 {
|
||||||
&& item.range.contains(&outline_match.range.end)
|
|
||||||
{
|
|
||||||
tree_matches.push(StringMatch {
|
tree_matches.push(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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_item_ix = string_match.candidate_index;
|
prev_item_ix = string_match.candidate_index + 1;
|
||||||
tree_matches.push(string_match);
|
tree_matches.push(string_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue