diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-13 18:35:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-13 18:35:08 +0000 |
commit | dab210d9b2d877ca9ed02bd7e0c8952d133965d3 (patch) | |
tree | 1db6002c00eb85781537f81f2b0d89a1dd04ca55 /crates | |
parent | 42e00032c6ba07eaf2f7d5886c60133c65d84cf5 (diff) | |
parent | 3d78f502bdb74a2d0b9cc8d9bb990e0a471dfb8c (diff) |
Merge #7263
7263: Use upstream TextSize API r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlights.rs | 14 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/injector.rs | 4 |
2 files changed, 3 insertions, 15 deletions
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?) |