@@ -42,7 +42,7 @@ export class Peritext implements Printable {
42
42
* @returns The point.
43
43
*/
44
44
public point ( id : ITimestampStruct = this . str . id , anchor : Anchor = Anchor . After ) : Point {
45
- return new Point ( this , id , anchor ) ;
45
+ return new Point ( this . str , id , anchor ) ;
46
46
}
47
47
48
48
/**
@@ -92,7 +92,7 @@ export class Peritext implements Printable {
92
92
* @returns A range with points in correct order.
93
93
*/
94
94
public rangeFromPoints ( p1 : Point , p2 : Point ) : Range {
95
- return Range . from ( this , p1 , p2 ) ;
95
+ return Range . from ( this . str , p1 , p2 ) ;
96
96
}
97
97
98
98
/**
@@ -103,28 +103,19 @@ export class Peritext implements Printable {
103
103
* @returns A range with the given start and end points.
104
104
*/
105
105
public range ( start : Point , end : Point ) : Range {
106
- return new Range ( this , start , end ) ;
106
+ return new Range ( this . str , start , end ) ;
107
107
}
108
108
109
109
/**
110
- * Creates a range from a view position and a length.
110
+ * A convenience method for creating a range from a view position and a length.
111
+ * See {@link Range.at} for more information.
111
112
*
112
113
* @param start Position in the text.
113
114
* @param length Length of the range.
114
115
* @returns A range from the given position with the given length.
115
116
*/
116
117
public rangeAt ( start : number , length : number = 0 ) : Range {
117
- const str = this . str ;
118
- if ( ! length ) {
119
- const startId = ! start ? str . id : str . find ( start - 1 ) || str . id ;
120
- const point = this . point ( startId , Anchor . After ) ;
121
- return this . range ( point , point . clone ( ) ) ;
122
- }
123
- const startId = str . find ( start ) || str . id ;
124
- const endId = str . find ( start + length - 1 ) || startId ;
125
- const startEndpoint = this . point ( startId , Anchor . Before ) ;
126
- const endEndpoint = this . point ( endId , Anchor . After ) ;
127
- return this . range ( startEndpoint , endEndpoint ) ;
118
+ return Range . at ( this . str , start , length ) ;
128
119
}
129
120
130
121
// --------------------------------------------------------------- Insertions
0 commit comments