diff options
Diffstat (limited to 'crates/ra_ide_db/src/line_index_utils.rs')
-rw-r--r-- | crates/ra_ide_db/src/line_index_utils.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_ide_db/src/line_index_utils.rs b/crates/ra_ide_db/src/line_index_utils.rs index f050fe77f..039a12c0d 100644 --- a/crates/ra_ide_db/src/line_index_utils.rs +++ b/crates/ra_ide_db/src/line_index_utils.rs | |||
@@ -7,6 +7,8 @@ | |||
7 | //! Code in this module applies this "to (Line, Column) after edit" | 7 | //! Code in this module applies this "to (Line, Column) after edit" |
8 | //! transformation. | 8 | //! transformation. |
9 | 9 | ||
10 | use std::convert::TryInto; | ||
11 | |||
10 | use ra_syntax::{TextRange, TextSize}; | 12 | use ra_syntax::{TextRange, TextSize}; |
11 | use ra_text_edit::{AtomTextEdit, TextEdit}; | 13 | use ra_text_edit::{AtomTextEdit, TextEdit}; |
12 | 14 | ||
@@ -139,14 +141,15 @@ impl Iterator for OffsetStepIter<'_> { | |||
139 | .text | 141 | .text |
140 | .char_indices() | 142 | .char_indices() |
141 | .filter_map(|(i, c)| { | 143 | .filter_map(|(i, c)| { |
144 | let i: TextSize = i.try_into().unwrap(); | ||
145 | let char_len = TextSize::of(c); | ||
142 | if c == '\n' { | 146 | if c == '\n' { |
143 | let next_offset = self.offset + TextSize::from_usize(i + 1); | 147 | let next_offset = self.offset + i + char_len; |
144 | let next = Step::Newline(next_offset); | 148 | let next = Step::Newline(next_offset); |
145 | Some((next, next_offset)) | 149 | Some((next, next_offset)) |
146 | } else { | 150 | } else { |
147 | let char_len = TextSize::of(c); | 151 | if !c.is_ascii() { |
148 | if char_len > TextSize::from_usize(1) { | 152 | let start = self.offset + i; |
149 | let start = self.offset + TextSize::from_usize(i); | ||
150 | let end = start + char_len; | 153 | let end = start + char_len; |
151 | let next = Step::Utf16Char(TextRange::new(start, end)); | 154 | let next = Step::Utf16Char(TextRange::new(start, end)); |
152 | let next_offset = end; | 155 | let next_offset = end; |