@@ -73,6 +73,20 @@ impl Range {
7373 std::cmp::max(self.anchor, self.head)
7474 }
7575
76+ /// The (inclusive) range of lines that the range overlaps.
77+ #[inline]
78+ #[must_use]
79+ pub fn line_range(&self, text: RopeSlice) -> (usize, usize) {
80+ let from = self.from();
81+ let to = if self.is_empty() {
82+ self.to()
83+ } else {
84+ prev_grapheme_boundary(text, self.to()).max(from)
85+ };
86+
87+ (text.char_to_line(from), text.char_to_line(to))
88+ }
89+
7690 /// `true` when head and anchor are at the same position.
7791 #[inline]
7892 pub fn is_empty(&self) -> bool {