aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-06 18:29:30 +0100
committerGitHub <[email protected]>2021-05-06 18:29:30 +0100
commitb37b709459a4ff881a91965ebf0c39e3a449c304 (patch)
tree49eba918834c5a4fec5a8d5de39589219c81c846 /crates/ide_db/src
parent3b4d5df840f1c6a077ad1886a98ef453811a599f (diff)
parent607d8a2f61e56fabb7a3bc5132592917fcdca970 (diff)
Merge #8718
8718: 1.52.0 r=SomeoneToIgnore a=matklad A lot of APIs we use in this release! Co-authored-by: Aleksey Kladov <[email protected]> Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/line_index.rs7
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 @@
3use std::iter; 3use std::iter;
4 4
5use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
6use stdx::partition_point;
7use syntax::{TextRange, TextSize}; 6use 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()));