From 3d78f502bdb74a2d0b9cc8d9bb990e0a471dfb8c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 13 Jan 2021 20:10:46 +0300 Subject: Use upstream TextSize API --- crates/ide/src/syntax_highlighting/highlights.rs | 14 ++------------ crates/ide/src/syntax_highlighting/injector.rs | 4 +--- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'crates') 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 @@ //! Collects a tree of highlighted ranges and flattens it. -use std::{cmp::Ordering, iter}; +use std::iter; use stdx::equal_range_by; use syntax::TextRange; @@ -52,7 +52,7 @@ impl Node { } let overlapping = - equal_range_by(&self.nested, |n| ordering(n.hl_range.range, hl_range.range)); + equal_range_by(&self.nested, |n| TextRange::ordering(n.hl_range.range, hl_range.range)); if overlapping.len() == 1 && self.nested[overlapping.start].hl_range.range.contains_range(hl_range.range) @@ -90,13 +90,3 @@ impl Node { } } } - -pub(super) fn ordering(r1: TextRange, r2: TextRange) -> Ordering { - if r1.end() <= r2.start() { - Ordering::Less - } else if r2.end() <= r1.start() { - Ordering::Greater - } else { - Ordering::Equal - } -} 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}; use stdx::equal_range_by; use syntax::{TextRange, TextSize}; -use super::highlights::ordering; - #[derive(Default)] pub(super) struct Injector { buf: String, @@ -33,7 +31,7 @@ impl Injector { &self.buf } pub(super) fn map_range_up(&self, range: TextRange) -> impl Iterator + '_ { - equal_range_by(&self.ranges, |&(r, _)| ordering(r, range)).filter_map(move |i| { + equal_range_by(&self.ranges, |&(r, _)| TextRange::ordering(r, range)).filter_map(move |i| { let (target_range, delta) = self.ranges[i]; let intersection = target_range.intersect(range).unwrap(); Some(intersection + delta?) -- cgit v1.2.3