mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 15:47:31 +00:00
Use upstream TextSize API
This commit is contained in:
parent
f84f5cb0ea
commit
3d78f502bd
3 changed files with 5 additions and 17 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1635,9 +1635,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "text-size"
|
name = "text-size"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a"
|
checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "text_edit"
|
name = "text_edit"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//! Collects a tree of highlighted ranges and flattens it.
|
//! Collects a tree of highlighted ranges and flattens it.
|
||||||
use std::{cmp::Ordering, iter};
|
use std::iter;
|
||||||
|
|
||||||
use stdx::equal_range_by;
|
use stdx::equal_range_by;
|
||||||
use syntax::TextRange;
|
use syntax::TextRange;
|
||||||
|
@ -52,7 +52,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
let overlapping =
|
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
|
if overlapping.len() == 1
|
||||||
&& self.nested[overlapping.start].hl_range.range.contains_range(hl_range.range)
|
&& 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ use std::ops::{self, Sub};
|
||||||
use stdx::equal_range_by;
|
use stdx::equal_range_by;
|
||||||
use syntax::{TextRange, TextSize};
|
use syntax::{TextRange, TextSize};
|
||||||
|
|
||||||
use super::highlights::ordering;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct Injector {
|
pub(super) struct Injector {
|
||||||
buf: String,
|
buf: String,
|
||||||
|
@ -33,7 +31,7 @@ impl Injector {
|
||||||
&self.buf
|
&self.buf
|
||||||
}
|
}
|
||||||
pub(super) fn map_range_up(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ {
|
pub(super) fn map_range_up(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ {
|
||||||
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 (target_range, delta) = self.ranges[i];
|
||||||
let intersection = target_range.intersect(range).unwrap();
|
let intersection = target_range.intersect(range).unwrap();
|
||||||
Some(intersection + delta?)
|
Some(intersection + delta?)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue