highlight: Skip injection codepath if there are no ranges found
This commit is contained in:
parent
077cd4970c
commit
9e765ceba6
1 changed files with 14 additions and 11 deletions
|
|
@ -712,17 +712,20 @@ where
|
|||
// to the highlighted document.
|
||||
if let Some(config) = language.and_then(&self.injection_callback) {
|
||||
if !content_nodes.is_empty() {
|
||||
match HighlightIterLayer::new(
|
||||
config,
|
||||
self.source,
|
||||
self.context,
|
||||
self.cancellation_flag,
|
||||
self.layers[0].depth + 1,
|
||||
self.layers[0]
|
||||
.intersect_ranges(&content_nodes, include_children),
|
||||
) {
|
||||
Ok(layer) => self.insert_layer(layer),
|
||||
Err(e) => return Some(Err(e)),
|
||||
let ranges = self.layers[0]
|
||||
.intersect_ranges(&content_nodes, include_children);
|
||||
if !ranges.is_empty() {
|
||||
match HighlightIterLayer::new(
|
||||
config,
|
||||
self.source,
|
||||
self.context,
|
||||
self.cancellation_flag,
|
||||
self.layers[0].depth + 1,
|
||||
ranges,
|
||||
) {
|
||||
Ok(layer) => self.insert_layer(layer),
|
||||
Err(e) => return Some(Err(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue