Allow matching of context items in outline view

This commit is contained in:
Antonio Scandurra 2022-01-14 11:09:02 +01:00
parent e7f1398f3a
commit a64ba8b687
4 changed files with 44 additions and 64 deletions

View file

@ -1864,15 +1864,11 @@ impl BufferSnapshot {
let item_node = mat.nodes_for_capture_index(item_capture_ix).next()?;
let range = item_node.start_byte()..item_node.end_byte();
let mut text = String::new();
let mut name_ranges = Vec::new();
let mut highlight_ranges = Vec::new();
for capture in mat.captures {
let node_is_name;
if capture.index == name_capture_ix {
node_is_name = true;
} else if capture.index == context_capture_ix {
node_is_name = false;
} else {
continue;
}
@ -1881,18 +1877,6 @@ impl BufferSnapshot {
if !text.is_empty() {
text.push(' ');
}
if node_is_name {
let mut start = text.len() as u32;
let end = start + range.len() as u32;
// When multiple names are captured, then the matcheable text
// includes the whitespace in between the names.
if !name_ranges.is_empty() {
start -= 1;
}
name_ranges.push(start..end);
}
let mut offset = range.start;
chunks.seek(offset);
@ -1926,7 +1910,6 @@ impl BufferSnapshot {
depth: stack.len() - 1,
range: self.anchor_after(range.start)..self.anchor_before(range.end),
text,
name_ranges,
highlight_ranges,
})
})