@@ -42,7 +42,7 @@ export class Peritext implements Printable {
4242 * @returns The point.
4343 */
4444 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 ) ;
4646 }
4747
4848 /**
@@ -92,7 +92,7 @@ export class Peritext implements Printable {
9292 * @returns A range with points in correct order.
9393 */
9494 public rangeFromPoints ( p1 : Point , p2 : Point ) : Range {
95- return Range . from ( this , p1 , p2 ) ;
95+ return Range . from ( this . str , p1 , p2 ) ;
9696 }
9797
9898 /**
@@ -103,28 +103,19 @@ export class Peritext implements Printable {
103103 * @returns A range with the given start and end points.
104104 */
105105 public range ( start : Point , end : Point ) : Range {
106- return new Range ( this , start , end ) ;
106+ return new Range ( this . str , start , end ) ;
107107 }
108108
109109 /**
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.
111112 *
112113 * @param start Position in the text.
113114 * @param length Length of the range.
114115 * @returns A range from the given position with the given length.
115116 */
116117 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 ) ;
128119 }
129120
130121 // --------------------------------------------------------------- Insertions
0 commit comments