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

Code before:
                        .clone(),
                )
                .build()
                .unwrap();
            let text_size = text_layout.size();
            let text_padding = 5.0;
            let x = size.width - text_size.width - text_padding * 2.0 - padding;
            let y = y + self.line_height * 2.0;
            let color = Color::rgb8(80, 161, 79);
            let rect =
                Size::new(text_size.width + text_padding * 2.0, self.line_height)
                    .to_rect()
                    .with_origin(Point::new(x, y));
            ctx.fill(rect, &color);
            ctx.draw_text(
                &text_layout,
                Point::new(
                    x + text_padding,
                    y + text_layout.y_offset(self.line_height),
                ),
            );
            rect
        } else {
            let color = match status {
                PluginStatus::Installed => LapceTheme::EDITOR_FOCUS,
                PluginStatus::Install => LapceTheme::EDITOR_FOREGROUND,
                PluginStatus::Upgrade(_) => LapceTheme::LAPCE_WARN,
                PluginStatus::Disabled => LapceTheme::EDITOR_DIM,
            };

            let status_x = text_layout.size().width + 20.0;
            let text_layout = ctx
                .text()
                .new_text_layout(format!("[ {status} ]"))
                .font(config.ui.font_family(), config.ui.font_size() as f64)
                .text_color(config.get_color_unchecked(color).clone())
                .build()
                .unwrap();
            ctx.draw_text(
                &text_layout,
                Point::new(
                    status_x,
                    y + self.line_height * 2.0
                        + text_layout.y_offset(self.line_height),
                ),
            );
            // if status is [installed, disabled, upgrade(x)], display the settings.svg
            let x = self.width - 24.0;
            let y = y + self.line_height * 2.2;
            let rect = Size::new(15.0, 15.0)
                .to_rect()

Review comment (suggestion):
pointless checking for `PluginStatus::Install` since you check for it higher
```rs
if status == PluginStatus::Install {
```

remove it with e.g. `PluginStatus::Disabled` and use `_ => LapceTheme...`

Code after:
                        .clone(),
                )
                .build()
                .unwrap();
            let text_size = text_layout.size();
            let text_padding = 5.0;
            let x = size.width - text_size.width - text_padding * 2.0 - padding;
            let y = y + self.line_height * 2.0;
            let color = Color::rgb8(80, 161, 79);
            let rect =
                Size::new(text_size.width + text_padding * 2.0, self.line_height)
                    .to_rect()
                    .with_origin(Point::new(x, y));
            ctx.fill(rect, &color);
            ctx.draw_text(
                &text_layout,
                Point::new(
                    x + text_padding,
                    y + text_layout.y_offset(self.line_height),
                ),
            );
            rect
        } else {
            let color = match status {
                PluginStatus::Installed => LapceTheme::EDITOR_FOCUS,
                PluginStatus::Upgrade(_) => LapceTheme::LAPCE_WARN,
                _ => LapceTheme::EDITOR_DIM,
            };

            let status_x = text_layout.size().width + 20.0;
            let text_layout = ctx
                .text()
                .new_text_layout(format!("[ {status} ]"))
                .font(config.ui.font_family(), config.ui.font_size() as f64)
                .text_color(config.get_color_unchecked(color).clone())
                .build()
                .unwrap();
            ctx.draw_text(
                &text_layout,
                Point::new(
                    status_x,
                    y + self.line_height * 2.0
                        + text_layout.y_offset(self.line_height),
                ),
            );
            // if status is [installed, disabled, upgrade(x)], display the settings.svg
            let x = self.width - 24.0;
            let y = y + self.line_height * 2.2;
            let rect = Size::new(15.0, 15.0)
                .to_rect()
                .with_origin(Point::new(x, y));