Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ted.rs')
-rw-r--r--crates/syntax/src/ted.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/syntax/src/ted.rs b/crates/syntax/src/ted.rs
index ad1d91bb0b..6fcbdd006c 100644
--- a/crates/syntax/src/ted.rs
+++ b/crates/syntax/src/ted.rs
@@ -5,6 +5,7 @@
use std::{mem, ops::RangeInclusive};
use parser::T;
+use rowan::TextSize;
use crate::{
SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken,
@@ -74,6 +75,12 @@ impl Position {
};
Position { repr }
}
+ pub fn offset(&self) -> TextSize {
+ match &self.repr {
+ PositionRepr::FirstChild(node) => node.text_range().start(),
+ PositionRepr::After(elem) => elem.text_range().end(),
+ }
+ }
}
pub fn insert(position: Position, elem: impl Element) {