aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--crates/ide/src/syntax_highlighting/highlights.rs14
-rw-r--r--crates/ide/src/syntax_highlighting/injector.rs4
3 files changed, 5 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f53eb7024..7b175ec67 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1635,9 +1635,9 @@ dependencies = [
1635 1635
1636[[package]] 1636[[package]]
1637name = "text-size" 1637name = "text-size"
1638version = "1.0.0" 1638version = "1.1.0"
1639source = "registry+https://github.com/rust-lang/crates.io-index" 1639source = "registry+https://github.com/rust-lang/crates.io-index"
1640checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" 1640checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a"
1641 1641
1642[[package]] 1642[[package]]
1643name = "text_edit" 1643name = "text_edit"
diff --git a/crates/ide/src/syntax_highlighting/highlights.rs b/crates/ide/src/syntax_highlighting/highlights.rs
index c6f0417ec..882a685a5 100644
--- a/crates/ide/src/syntax_highlighting/highlights.rs
+++ b/crates/ide/src/syntax_highlighting/highlights.rs
@@ -1,5 +1,5 @@
1//! Collects a tree of highlighted ranges and flattens it. 1//! Collects a tree of highlighted ranges and flattens it.
2use std::{cmp::Ordering, iter}; 2use std::iter;
3 3
4use stdx::equal_range_by; 4use stdx::equal_range_by;
5use syntax::TextRange; 5use syntax::TextRange;
@@ -52,7 +52,7 @@ impl Node {
52 } 52 }
53 53
54 let overlapping = 54 let overlapping =
55 equal_range_by(&self.nested, |n| ordering(n.hl_range.range, hl_range.range)); 55 equal_range_by(&self.nested, |n| TextRange::ordering(n.hl_range.range, hl_range.range));
56 56
57 if overlapping.len() == 1 57 if overlapping.len() == 1
58 && self.nested[overlapping.start].hl_range.range.contains_range(hl_range.range) 58 && self.nested[overlapping.start].hl_range.range.contains_range(hl_range.range)
@@ -90,13 +90,3 @@ impl Node {
90 } 90 }
91 } 91 }
92} 92}
93
94pub(super) fn ordering(r1: TextRange, r2: TextRange) -> Ordering {
95 if r1.end() <= r2.start() {
96 Ordering::Less
97 } else if r2.end() <= r1.start() {
98 Ordering::Greater
99 } else {
100 Ordering::Equal
101 }
102}
diff --git a/crates/ide/src/syntax_highlighting/injector.rs b/crates/ide/src/syntax_highlighting/injector.rs
index fd4025694..24ff473ec 100644
--- a/crates/ide/src/syntax_highlighting/injector.rs
+++ b/crates/ide/src/syntax_highlighting/injector.rs
@@ -5,8 +5,6 @@ use std::ops::{self, Sub};
5use stdx::equal_range_by; 5use stdx::equal_range_by;
6use syntax::{TextRange, TextSize}; 6use syntax::{TextRange, TextSize};
7 7
8use super::highlights::ordering;
9
10#[derive(Default)] 8#[derive(Default)]
11pub(super) struct Injector { 9pub(super) struct Injector {
12 buf: String, 10 buf: String,
@@ -33,7 +31,7 @@ impl Injector {
33 &self.buf 31 &self.buf
34 } 32 }
35 pub(super) fn map_range_up(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { 33 pub(super) fn map_range_up(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ {
36 equal_range_by(&self.ranges, |&(r, _)| ordering(r, range)).filter_map(move |i| { 34 equal_range_by(&self.ranges, |&(r, _)| TextRange::ordering(r, range)).filter_map(move |i| {
37 let (target_range, delta) = self.ranges[i]; 35 let (target_range, delta) = self.ranges[i];
38 let intersection = target_range.intersect(range).unwrap(); 36 let intersection = target_range.intersect(range).unwrap();
39 Some(intersection + delta?) 37 Some(intersection + delta?)