fn next_match_right(
        &self,
        origin: Point<usize>,
        side: Side,
        max_lines: Option<usize>,
    ) -> Option<Match> {
        let start = self.line_search_left(origin);
        let mut end = start;

        // Limit maximum number of lines searched.
        let total_lines = self.total_lines();
        end = match max_lines {
            Some(max_lines) => {
                let line = (start.line + total_lines - max_lines) % total_lines;
                Point::new(line, self.cols() - 1)
            },
            _ => end.sub_absolute(self, Boundary::Wrap, 1),
        };

        let mut regex_iter = RegexIter::new(start, end, Direction::Right, &self).peekable();

        // Check if there's any match at all.
        let first_match = regex_iter.peek()?.clone();

        let regex_match = regex_iter
            .find(|regex_match| {
                let match_point = Self::match_side(&regex_match, side);

                // If the match's point is beyond the origin, we're done.
                match_point.line > start.line
                    || match_point.line < origin.line
                    || (match_point.line == origin.line && match_point.col >= origin.col)
            })
            .unwrap_or(first_match);

        Some(regex_match)
    }
/// Find the next match to the right of the origin.
Find the next match to the right of the origin.
Find the next match to the right of the origin .
fn next_match_right(
        &self,
        origin: Point<usize>,
        side: Side,
        max_lines: Option<usize>,
    ) -> Option<Match> {
        let start = self.line_search_left(origin);
        let mut end = start;
        // Limit maximum number of lines searched.
        let total_lines = self.total_lines();
        end = match max_lines {
            Some(max_lines) => {
                let line = (start.line + total_lines - max_lines) % total_lines;
                Point::new(line, self.cols() - 1)
            },
            _ => end.sub_absolute(self, Boundary::Wrap, 1),
        };
        let mut regex_iter = RegexIter::new(start, end, Direction::Right, &self).peekable();
        // Check if there's any match at all.
        let first_match = regex_iter.peek()?.clone();
        let regex_match = regex_iter
            .find(|regex_match| {
                let match_point = Self::match_side(&regex_match, side);
                // If the match's point is beyond the origin, we're done.
                match_point.line > start.line
                    || match_point.line < origin.line
                    || (match_point.line == origin.line && match_point.col >= origin.col)
            })
            .unwrap_or(first_match);
        Some(regex_match)
    }
fn next_match_right ( & self , origin : Point < usize > , side : Side , max_lines : Option < usize > , ) -> Option < Match > { let start = self . line_search_left ( origin ) ; let mut end = start ; // Limit maximum number of lines searched. let total_lines = self . total_lines ( ) ; end = match max_lines { Some ( max_lines ) => { let line = ( start . line + total_lines - max_lines ) % total_lines ; Point :: new ( line , self . cols ( ) - 1 ) } , _ => end . sub_absolute ( self , Boundary :: Wrap , 1 ) , } ; let mut regex_iter = RegexIter :: new ( start , end , Direction :: Right , & self ) . peekable ( ) ; // Check if there's any match at all. let first_match = regex_iter . peek ( ) ? . clone ( ) ; let regex_match = regex_iter . find ( | regex_match | { let match_point = Self :: match_side ( & regex_match , side ) ; // If the match's point is beyond the origin, we're done. match_point . line > start . line || match_point . line < origin . line || ( match_point . line == origin . line && match_point . col >= origin . col ) } ) . unwrap_or ( first_match ) ; Some ( regex_match ) }
Find the next match to the right of the origin.
Find the next match to the right of the origin .
&self
origin
Point<usize>
side
Side
max_lines
Option<usize>
&self
origin
Point<usize>
side
Side
max_lines
Option<usize>