diff options
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/line_index.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/ide_db/src/line_index.rs b/crates/ide_db/src/line_index.rs index 8e9d8cca2..816edfe6a 100644 --- a/crates/ide_db/src/line_index.rs +++ b/crates/ide_db/src/line_index.rs | |||
@@ -3,7 +3,6 @@ | |||
3 | use std::iter; | 3 | use std::iter; |
4 | 4 | ||
5 | use rustc_hash::FxHashMap; | 5 | use rustc_hash::FxHashMap; |
6 | use stdx::partition_point; | ||
7 | use syntax::{TextRange, TextSize}; | 6 | use syntax::{TextRange, TextSize}; |
8 | 7 | ||
9 | #[derive(Clone, Debug, PartialEq, Eq)] | 8 | #[derive(Clone, Debug, PartialEq, Eq)] |
@@ -97,7 +96,7 @@ impl LineIndex { | |||
97 | } | 96 | } |
98 | 97 | ||
99 | pub fn line_col(&self, offset: TextSize) -> LineCol { | 98 | pub fn line_col(&self, offset: TextSize) -> LineCol { |
100 | let line = partition_point(&self.newlines, |&it| it <= offset) - 1; | 99 | let line = self.newlines.partition_point(|&it| it <= offset) - 1; |
101 | let line_start_offset = self.newlines[line]; | 100 | let line_start_offset = self.newlines[line]; |
102 | let col = offset - line_start_offset; | 101 | let col = offset - line_start_offset; |
103 | LineCol { line: line as u32, col: col.into() } | 102 | LineCol { line: line as u32, col: col.into() } |
@@ -118,8 +117,8 @@ impl LineIndex { | |||
118 | } | 117 | } |
119 | 118 | ||
120 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { | 119 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { |
121 | let lo = partition_point(&self.newlines, |&it| it < range.start()); | 120 | let lo = self.newlines.partition_point(|&it| it < range.start()); |
122 | let hi = partition_point(&self.newlines, |&it| it <= range.end()); | 121 | let hi = self.newlines.partition_point(|&it| it <= range.end()); |
123 | let all = iter::once(range.start()) | 122 | let all = iter::once(range.start()) |
124 | .chain(self.newlines[lo..hi].iter().copied()) | 123 | .chain(self.newlines[lo..hi].iter().copied()) |
125 | .chain(iter::once(range.end())); | 124 | .chain(iter::once(range.end())); |