aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/line_index.rs
diff options
context:
space:
mode:
authorBernardo <[email protected]>2018-12-22 11:59:48 +0000
committerBernardo <[email protected]>2018-12-25 19:03:14 +0000
commit36f2b1f3b9c36ace65852d971f998a090cf9b5d5 (patch)
tree7844f2e759fe477f69b8ba449490a6e4fca58977 /crates/ra_editor/src/line_index.rs
parent1c44ba0f04a0997617d517111d0a08245f0dacac (diff)
iterate over `Step`s which are either, newlines or multibyte chars
Diffstat (limited to 'crates/ra_editor/src/line_index.rs')
-rw-r--r--crates/ra_editor/src/line_index.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/ra_editor/src/line_index.rs b/crates/ra_editor/src/line_index.rs
index 7d9b8d79f..c29e2e49a 100644
--- a/crates/ra_editor/src/line_index.rs
+++ b/crates/ra_editor/src/line_index.rs
@@ -15,9 +15,9 @@ pub struct LineCol {
15} 15}
16 16
17#[derive(Clone, Debug, Hash, PartialEq, Eq)] 17#[derive(Clone, Debug, Hash, PartialEq, Eq)]
18struct Utf16Char { 18pub(crate) struct Utf16Char {
19 start: TextUnit, 19 pub(crate) start: TextUnit,
20 end: TextUnit, 20 pub(crate) end: TextUnit,
21} 21}
22 22
23impl Utf16Char { 23impl Utf16Char {
@@ -122,7 +122,13 @@ impl LineIndex {
122 } 122 }
123 123
124 pub(crate) fn newlines(&self) -> &[TextUnit] { 124 pub(crate) fn newlines(&self) -> &[TextUnit] {
125 &self.newlines[1..] 125 &self.newlines[..]
126 }
127
128 pub(crate) fn utf16_chars(&self, newline_idx: usize) -> Option<&[Utf16Char]> {
129 self.utf16_lines
130 .get(&(newline_idx as u32))
131 .map(|x| x.as_slice())
126 } 132 }
127} 133}
128 134