Repository: lapce/lapce
File: lapce-ui/src/editor.rs (Rust)

Code before:
        data: &LapceEditorBufferData,
        screen_lines: &ScreenLines,
    ) {
        if screen_lines.lines.is_empty() {
            return;
        }

        let cursor_offset = data.editor.cursor.offset();

        if let Some(char_at_cursor) = data.doc.buffer().char_at_offset(cursor_offset)
        {
            if is_bracket(char_at_cursor) {
                if let Some(syntax) = data.doc.syntax() {
                    if let Some(new_offset) =
                        syntax.find_matching_pair(cursor_offset)
                    {
                        Self::highlight_char(ctx, data, screen_lines, cursor_offset);
                        Self::highlight_char(ctx, data, screen_lines, new_offset);
                    }
                }
            } else {
                if let Some(syntax) = data.doc.syntax() {
                    let end_line = *screen_lines.lines.last().unwrap();
                    let end = data.doc.buffer().offset_of_line(end_line + 1);

                    for (indice, c) in
                        data.doc.buffer().char_indices_iter(cursor_offset..end)
                    {
                        if is_bracket(c) && matching_pair_direction(c) == Some(false)
                        {
                            let closing_bracket_offset = indice + cursor_offset;

                            if let Some(opening_bracket_offset) =
                                syntax.find_matching_pair(closing_bracket_offset)
                            {
                                if opening_bracket_offset < cursor_offset
                                    && cursor_offset < closing_bracket_offset
                                {
                                    Self::highlight_char(
                                        ctx,
                                        data,
                                        screen_lines,
                                        opening_bracket_offset,
                                    );
                                    Self::highlight_char(
                                        ctx,
                                        data,
                                        screen_lines,
                                        closing_bracket_offset,
                                    );
                                    break;

Review comment (suggestion):
```suggestion
                    for (index, c) in
```

Code after:
                        .text()
                        .new_text_layout(diagnostic.diagnostic.message.clone())
                        .font(
                            data.config.ui.font_family(),
                            data.config.ui.font_size() as f64,
                        )
                        .text_color(
                            data.config
                                .get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
                                .clone(),
                        )
                        .max_width(data.editor.size.borrow().width - 20.0)
                        .build()
                        .unwrap();
                    let text_size = text_layout.size();
                    let mut text_height = text_size.height;

                    let related = diagnostic
                        .diagnostic
                        .related_information
                        .map(|related| {
                            related
                                .iter()
                                .map(|i| {
                                    let text_layout = ctx
                                        .text()
                                        .new_text_layout(i.message.clone())
                                        .font(
                                            data.config.ui.font_family(),
                                            data.config.ui.font_size() as f64,
                                        )
                                        .text_color(
                                            data.config
                                                .get_color_unchecked(
                                                    LapceTheme::EDITOR_FOREGROUND,
                                                )
                                                .clone(),
                                        )
                                        .max_width(
                                            data.editor.size.borrow().width - 20.0,
                                        )
                                        .build()
                                        .unwrap();
                                    text_height += 10.0 + text_layout.size().height;
                                    text_layout
                                })
                                .collect::<Vec<PietTextLayout>>()
                        })
                        .unwrap_or_else(Vec::new);

                    let rect = Rect::ZERO