diff options
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 91f27aa2a..028b55902 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -372,22 +372,26 @@ impl HighlightedRangeStack { | |||
372 | } else { | 372 | } else { |
373 | let maybe_idx = | 373 | let maybe_idx = |
374 | prev.iter().position(|parent| parent.range.contains(child.range.start())); | 374 | prev.iter().position(|parent| parent.range.contains(child.range.start())); |
375 | if let (Some(_), Some(idx)) = (overwrite_parent, maybe_idx) { | 375 | match (overwrite_parent, maybe_idx) { |
376 | Self::intersect_partial(&mut prev[idx], &child); | 376 | (Some(_), Some(idx)) => { |
377 | let insert_idx = if prev[idx].range.is_empty() { | 377 | Self::intersect_partial(&mut prev[idx], &child); |
378 | prev.remove(idx); | 378 | let insert_idx = if prev[idx].range.is_empty() { |
379 | idx | 379 | prev.remove(idx); |
380 | } else { | 380 | idx |
381 | idx + 1 | 381 | } else { |
382 | }; | 382 | idx + 1 |
383 | prev.insert(insert_idx, child); | 383 | }; |
384 | } else if let None = maybe_idx { | 384 | prev.insert(insert_idx, child); |
385 | let idx = prev | 385 | } |
386 | .binary_search_by_key(&child.range.start(), |range| range.range.start()) | 386 | (_, None) => { |
387 | .unwrap_or_else(|x| x); | 387 | let idx = prev |
388 | prev.insert(idx, child); | 388 | .binary_search_by_key(&child.range.start(), |range| range.range.start()) |
389 | } else { | 389 | .unwrap_or_else(|x| x); |
390 | unreachable!("child range should be completely contained in parent range"); | 390 | prev.insert(idx, child); |
391 | } | ||
392 | _ => { | ||
393 | unreachable!("child range should be completely contained in parent range"); | ||
394 | } | ||
391 | } | 395 | } |
392 | } | 396 | } |
393 | } | 397 | } |