aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-31 12:52:29 +0100
committerAleksey Kladov <[email protected]>2018-08-31 12:52:29 +0100
commit05a9d42f542c8eb876d06791579d948b2f571e04 (patch)
tree33b5962641f57d65b8545b477885fcfadbbe801c /crates/libsyntax2/src
parent8fc7f438c4347e027deda5cda4bcd5e560610bb7 (diff)
tweak extend selection
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r--crates/libsyntax2/src/yellow/syntax_text.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/yellow/syntax_text.rs b/crates/libsyntax2/src/yellow/syntax_text.rs
index b855687c4..280bedd78 100644
--- a/crates/libsyntax2/src/yellow/syntax_text.rs
+++ b/crates/libsyntax2/src/yellow/syntax_text.rs
@@ -61,6 +61,18 @@ impl<'a> SyntaxText<'a> {
61 }); 61 });
62 SyntaxText { node: self.node, range } 62 SyntaxText { node: self.node, range }
63 } 63 }
64 pub fn char_at(&self, offset: TextUnit) -> Option<char> {
65 let mut start: TextUnit = 0.into();
66 for chunk in self.chunks() {
67 let end = start + TextUnit::of_str(chunk);
68 if start <= offset && offset < end {
69 let off: usize = u32::from(offset - start) as usize;
70 return Some(chunk[off..].chars().next().unwrap());
71 }
72 start = end;
73 }
74 None
75 }
64} 76}
65 77
66impl<'a> fmt::Debug for SyntaxText<'a> { 78impl<'a> fmt::Debug for SyntaxText<'a> {