fn bounds_of_range_around_line(&self, line: usize, n: usize, width: usize) -> (usize, usize) {
        let space = n / 2;

        // Roll the start back n/2 spaces. If fewer, save the diff.
        let mut start = line;
        let mut start_diff = 0;
        let mut i = 0;
        while i < space {
            if let Some(prev) = self.tree.lines.lines[start].prev {
                i += self.visual_lines_for_line(start, width);
                start = prev;
            } else {
                start_diff = space - i;
                break;
            }
        }

        // Roll the end forward n/2 + start_diff spaces. If fewer, save the diff.
        let mut end = line;
        let mut end_diff = 0;
        let end_max = space + n % 2 + start_diff;
        let mut i = 0;
        while i < end_max {
            let next = self.tree.lines.lines[end].next;
            if let Some(_) = self.tree.lines.lines.get(next) {
                i += self.visual_lines_for_line(end, width);
                end = next;
            } else {
                end += 1;
                end_diff = end_max - i - 1;
                break;
            }
        }

        // Roll the start back at most an additional end_diff spaces.
        let mut i = 0;
        while i < end_diff {
            if let Some(prev) = self.tree.lines.lines[start].prev {
                i += self.visual_lines_for_line(start, width);
                start = prev;
            } else {
                break;
            }
        }

        (start, end)
    }
/// Find the bounds of the range of n consecutively renderable lines
/// around a given line.
///
/// Lines are considered consecutive if they follow each other in the
/// doubly-linked list in which a line's `next` and `prev` fields comprise
/// the edges.
///
/// The range will include n/2 lines above and n/2 lines below the given line.
/// If the given line is within n/2 lines of the top or bottom of the tree,
/// the remaining space will be used on the other side.
Find the bounds of the range of n consecutively renderable lines
around a given line.

Lines are considered consecutive if they follow each other in the
doubly-linked list in which a line's `next` and `prev` fields comprise
the edges.

The range will include n/2 lines above and n/2 lines below the given line.
If the given line is within n/2 lines of the top or bottom of the tree,
the remaining space will be used on the other side.
Find the bounds of the range of n consecutively renderable lines around a given line . Lines are considered consecutive if they follow each other in the doubly - linked list in which a line ' s ` next ` and ` prev ` fields comprise the edges . The range will include n / 2 lines above and n / 2 lines below the given line . If the given line is within n / 2 lines of the top or bottom of the tree the remaining space will be used on the other side .
fn bounds_of_range_around_line(&self, line: usize, n: usize, width: usize) -> (usize, usize) {
        let space = n / 2;
        // Roll the start back n/2 spaces. If fewer, save the diff.
        let mut start = line;
        let mut start_diff = 0;
        let mut i = 0;
        while i < space {
            if let Some(prev) = self.tree.lines.lines[start].prev {
                i += self.visual_lines_for_line(start, width);
                start = prev;
            } else {
                start_diff = space - i;
                break;
            }
        }
        // Roll the end forward n/2 + start_diff spaces. If fewer, save the diff.
        let mut end = line;
        let mut end_diff = 0;
        let end_max = space + n % 2 + start_diff;
        let mut i = 0;
        while i < end_max {
            let next = self.tree.lines.lines[end].next;
            if let Some(_) = self.tree.lines.lines.get(next) {
                i += self.visual_lines_for_line(end, width);
                end = next;
            } else {
                end += 1;
                end_diff = end_max - i - 1;
                break;
            }
        }
        // Roll the start back at most an additional end_diff spaces.
        let mut i = 0;
        while i < end_diff {
            if let Some(prev) = self.tree.lines.lines[start].prev {
                i += self.visual_lines_for_line(start, width);
                start = prev;
            } else {
                break;
            }
        }
        (start, end)
    }
fn bounds_of_range_around_line ( & self , line : usize , n : usize , width : usize ) -> ( usize , usize ) { let space = n / 2 ; // Roll the start back n/2 spaces. If fewer, save the diff. let mut start = line ; let mut start_diff = 0 ; let mut i = 0 ; while i < space { if let Some ( prev ) = self . tree . lines . lines [ start ] . prev { i += self . visual_lines_for_line ( start , width ) ; start = prev ; } else { start_diff = space - i ; break ; } } // Roll the end forward n/2 + start_diff spaces. If fewer, save the diff. let mut end = line ; let mut end_diff = 0 ; let end_max = space + n % 2 + start_diff ; let mut i = 0 ; while i < end_max { let next = self . tree . lines . lines [ end ] . next ; if let Some ( _ ) = self . tree . lines . lines . get ( next ) { i += self . visual_lines_for_line ( end , width ) ; end = next ; } else { end += 1 ; end_diff = end_max - i - 1 ; break ; } } // Roll the start back at most an additional end_diff spaces. let mut i = 0 ; while i < end_diff { if let Some ( prev ) = self . tree . lines . lines [ start ] . prev { i += self . visual_lines_for_line ( start , width ) ; start = prev ; } else { break ; } } ( start , end ) }
Find the bounds of the range of n consecutively renderable lines
around a given line.
Find the bounds of the range of n consecutively renderable lines around a given line .
&self
line
usize
n
usize
width
usize
&self
line
usize
n
usize
width
usize