aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r--crates/ra_ide_db/src/line_index.rs14
-rw-r--r--crates/ra_ide_db/src/line_index_utils.rs2
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ra_ide_db/src/line_index.rs
index b9db5c276..8ae745ff2 100644
--- a/crates/ra_ide_db/src/line_index.rs
+++ b/crates/ra_ide_db/src/line_index.rs
@@ -59,7 +59,7 @@ impl LineIndex {
59 } 59 }
60 60
61 let char_len = TextUnit::of_char(c); 61 let char_len = TextUnit::of_char(c);
62 if char_len.to_usize() > 1 { 62 if char_len > TextUnit::from_usize(1) {
63 utf16_chars.push(Utf16Char { start: curr_col, end: curr_col + char_len }); 63 utf16_chars.push(Utf16Char { start: curr_col, end: curr_col + char_len });
64 } 64 }
65 65
@@ -101,12 +101,12 @@ impl LineIndex {
101 .filter(|it| !it.is_empty()) 101 .filter(|it| !it.is_empty())
102 } 102 }
103 103
104 fn utf8_to_utf16_col(&self, line: u32, mut col: TextUnit) -> usize { 104 fn utf8_to_utf16_col(&self, line: u32, col: TextUnit) -> usize {
105 if let Some(utf16_chars) = self.utf16_lines.get(&line) { 105 if let Some(utf16_chars) = self.utf16_lines.get(&line) {
106 let mut correction = TextUnit::from_usize(0); 106 let mut correction = 0;
107 for c in utf16_chars { 107 for c in utf16_chars {
108 if col >= c.end { 108 if col >= c.end {
109 correction += c.len() - TextUnit::from_usize(1); 109 correction += c.len().to_usize() - 1;
110 } else { 110 } else {
111 // From here on, all utf16 characters come *after* the character we are mapping, 111 // From here on, all utf16 characters come *after* the character we are mapping,
112 // so we don't need to take them into account 112 // so we don't need to take them into account
@@ -114,10 +114,10 @@ impl LineIndex {
114 } 114 }
115 } 115 }
116 116
117 col -= correction; 117 col.to_usize() - correction
118 } else {
119 col.to_usize()
118 } 120 }
119
120 col.to_usize()
121 } 121 }
122 122
123 fn utf16_to_utf8_col(&self, line: u32, col: u32) -> TextUnit { 123 fn utf16_to_utf8_col(&self, line: u32, col: u32) -> TextUnit {
diff --git a/crates/ra_ide_db/src/line_index_utils.rs b/crates/ra_ide_db/src/line_index_utils.rs
index 75a498151..2ebbabdc6 100644
--- a/crates/ra_ide_db/src/line_index_utils.rs
+++ b/crates/ra_ide_db/src/line_index_utils.rs
@@ -145,7 +145,7 @@ impl Iterator for OffsetStepIter<'_> {
145 Some((next, next_offset)) 145 Some((next, next_offset))
146 } else { 146 } else {
147 let char_len = TextUnit::of_char(c); 147 let char_len = TextUnit::of_char(c);
148 if char_len.to_usize() > 1 { 148 if char_len > TextUnit::from_usize(1) {
149 let start = self.offset + TextUnit::from_usize(i); 149 let start = self.offset + TextUnit::from_usize(i);
150 let end = start + char_len; 150 let end = start + char_len;
151 let next = Step::Utf16Char(TextRange::from_to(start, end)); 151 let next = Step::Utf16Char(TextRange::from_to(start, end));