```rust
fn draw(
        &mut self,
        frame: &mut Frame,
        area: Rect,
        data: Option<&FileMatchData>,
        line_buffer: usize,
        replace: &str,
        focus: bool,
    ) {
        let Some((line_map, match_positions)) = data else {
            self.len = 0;
            return;
        };

        self.len = match_positions.len();
        let mut scroll_offset = 0;
        let replace = "hello\nthe\nworld";
        let replace_queue = replace.split('\n').collect::<Vec<_>>();

        const CURSOR: &str = "> ";
        let line_number_padding = match_positions.last().unwrap().end.0.to_string().len();
        let text = match_positions
            .iter()
            .enumerate()
            .flat_map(
                |(
                    match_index,
                    MatchPosition {
                        char_range: _,
                        start,
                        end,
                    },
                )| {
                    let mut lines = Vec::new();
                    let single_line_match = start.0 == end.0;
                    for line_number in
                        (start.0.saturating_sub(line_buffer))..end.0 + line_buffer + 1
                    {
                        if let Some(origin) = line_map.get(&line_number) {
                            let origin = origin.as_str();
                            let line_number_string = (line_number + 1).to_string();
                            let padded_line_number = " "
                                .repeat((line_number_padding - line_number_string.len()).max(0))
                                + &line_number_string
                                + " ";
                            if (start.0..end.0 + 1).contains(&line_number) {
                                let mut line = Line::raw("");
                                line.push_span(Span::raw(if focus && match_index == self.index {
                                    Cow::from(CURSOR)
                                } else {
                                    " ".repeat(CURSOR.len()).into()
                                }));
                                line.push_span(Span::raw(padded_line_number));
                                if line_number == start.0 {
                                    line.push_span(Span::raw(&origin[..start.1]));
                                }
                                if single_line_match {
                                    if line_number == start.0 {
                                        line.push_span(Span::styled(
                                            &origin[start.1..end.1],
                                            Style::new().fg(ratatui::style::Color::Red),
                                        ));
                                    }
                                } else if line_number == start.0 {
                                    line.push_span(Span::styled(
                                        &origin[start.1..],
                                        Style::new().fg(ratatui::style::Color::Red),
                                    ));
                                } else if line_number == end.0 {
                                    line.push_span(Span::styled(
                                        &origin[..end.1],
                                        Style::new().fg(ratatui::style::Color::Red),
                                    ));
                                } else {
                                    line.push_span(Span::styled(
                                        origin,
                                        Style::new().fg(ratatui::style::Color::Red),
                                    ));
                                }
                                let mut after: Option<Vec<Line>> = None;
                                if line_number == end.0 {
                                    if !replace_queue.is_empty() {
                                        line.push_span(Span::styled(
                                            replace_queue[0],
                                            Style::new().fg(ratatui::style::Color::Green),
                                        ));
                                    }
                                    if replace_queue.len() == 1 {
                                        line.push_span(Span::raw(&origin[end.1..]));
                                    } else if replace_queue.len() > 1 {
                                        after = Some(Vec::new());
                                        let iter = replace_queue.iter().skip(1);
                                        iter.enumerate().for_each(|(i, s)| {
                                            let mut spans = vec![Span::styled(
                                                " ".repeat(line_number_padding + 1) + *s,
                                                Style::new().fg(ratatui::style::Color::Green),
                                            )];
                                            if i + 2 == replace_queue.len() {
                                                spans.push(Span::raw(&origin[end.1..]));
                                            }
                                            after.as_mut().unwrap().push(Line::from(spans));
                                        });
                                    }
                                }
                                lines.push(line);
                                if let Some(ls) = after {
                                    lines.extend(ls);
                                }
                            } else {
                                lines.push(Line::styled(
                                    " ".repeat(CURSOR.len()) + &padded_line_number + origin,
                                    Style::new().fg(ratatui::style::Color::DarkGray),
                                ));
                            }
                        } else {
                            break;
                        }
                    }
                    if match_index + 1 < match_positions.len() {
                        lines.push(Line::from("-".repeat(area.width.into())));
                    }
                    if match_index <= self.index {
                        scroll_offset += lines.len();
                    }
                    lines
                },
            )
            .collect::<Vec<_>>();

        frame.render_widget(
            Paragraph::new(Text::from(text)).scroll((
                if scroll_offset > area.height.into() {
                    (scroll_offset - area.height as usize).try_into().unwrap()
                } else {
                    0
                },
                0,
            )),
            area,
        );
    }
```

help me refactor & rename where necessary