2424@total_ordering
2525class RangeSpec (NamedTuple ):
2626 """
27- Represents a range of lines in a text, with start and end indices and indentation.
27+ Represents a range of lines in a text, with 0-based start and end indices and indentation.
2828
2929 This class is used to specify a range of lines in a text, typically for
3030 text manipulation operations. It includes methods for comparing ranges,
3131 modifying the range, and performing operations on text using the range.
3232
3333 Attributes:
34- start (int): The starting line index of the range.
35- end (int): The ending line index of the range (exclusive).
36- indent (int): The indentation level of the range.
34+ start (int): The starting 0-based index of the range.
35+ end (int): The ending 0-based index of the range (exclusive).
36+ indent (int): The indentation level at the start of the range.
3737 """
3838 start : int
3939 end : int
@@ -75,7 +75,7 @@ def collapsed(self):
7575 return self .set_line_count (0 )
7676
7777 def set_line_count (self , range_len : int ):
78- """Return a new RangeSpec with the specified line count."""
78+ """Return a new RangeSpec with the specified line count by adjusting its end ."""
7979 return self ._replace (end = self .start + range_len )
8080
8181 def inc (self , count : int = 1 ):
@@ -91,7 +91,7 @@ def read(self, src: Sequence[str]) -> Sequence[str]:
9191 return src [self .start :self .end ]
9292
9393 def write (self , src : Sequence [str ], target : Sequence [str ]):
94- """Write the source lines into the target sequence at the position specified by this range."""
94+ """Write the source lines into the target sequence at the index position specified by this range."""
9595 target [self .start :self .end ] = src
9696
9797 def delete (self , src : Sequence [str ]) -> Sequence [str ]:
@@ -129,13 +129,15 @@ def from_line_marker(
129129 - value: The line to search for.
130130 - offset: The number of matches to skip before returning a result.
131131 0 skips no match and returns the first match, 1 returns the second match, and so on.
132- search_range (RangeSpec, optional): The range to search within. Defaults to None, which means search the entire list.
132+ search_range (RangeSpec, optional): The range to search within. Defaults to None, which means
133+ search the entire list.
133134
134135 Returns:
135136 RangeSpec: A RangeSpec object representing the found line, or None if no match is found.
136137
137138 Raises:
138- ValueError: If there are multiple matches and no offset is specified, or if the offset exceeds the number of matches.
139+ ValueError: If there are multiple matches and no offset is specified, or if the offset exceeds the
140+ number of matches.
139141
140142 Note:
141143 - The method prioritizes match types in the order: exact, stripped, normalized, partial.
@@ -248,7 +250,6 @@ class IdentifierBoundaries(NamedTuple):
248250 body : RangeSpec
249251
250252 def __str__ (self ):
251- """Return a string representation of the IdentifierBoundaries."""
252253 return f'IdentifierBoundaries({ self .whole } (BODY: { self .body } ) )'
253254
254255 @property
0 commit comments