diff options
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlights.rs | 14 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/injector.rs | 4 |
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]] |
1637 | name = "text-size" | 1637 | name = "text-size" |
1638 | version = "1.0.0" | 1638 | version = "1.1.0" |
1639 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1639 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1640 | checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" | 1640 | checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a" |
1641 | 1641 | ||
1642 | [[package]] | 1642 | [[package]] |
1643 | name = "text_edit" | 1643 | name = "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. |
2 | use std::{cmp::Ordering, iter}; | 2 | use std::iter; |
3 | 3 | ||
4 | use stdx::equal_range_by; | 4 | use stdx::equal_range_by; |
5 | use syntax::TextRange; | 5 | use 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 | |||
94 | pub(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}; | |||
5 | use stdx::equal_range_by; | 5 | use stdx::equal_range_by; |
6 | use syntax::{TextRange, TextSize}; | 6 | use syntax::{TextRange, TextSize}; |
7 | 7 | ||
8 | use super::highlights::ordering; | ||
9 | |||
10 | #[derive(Default)] | 8 | #[derive(Default)] |
11 | pub(super) struct Injector { | 9 | pub(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?) |