Repository: alacritty/alacritty
File: alacritty_terminal/src/term/mod.rs (Rust)

Code before:
        }
    }
}

impl<'a, C> Iterator for RenderableCellsIter<'a, C> {
    type Item = RenderableCell;

    /// Gets the next renderable cell.
    ///
    /// Skips empty (background) cells and applies any flags to the cell state
    /// (eg. invert fg and bg colors).
    #[inline]
    fn next(&mut self) -> Option<Self::Item> {
        loop {
            if self.cursor.point.line == self.inner.line()
                && self.cursor.point.col == self.inner.column()
            {
                if self.cursor.rendered {
                    // Handle cell below cursor.
                    let cell = self.inner.next()?;
                    let mut cell = RenderableCell::new(self, cell);

                    if self.cursor.key.style == CursorStyle::Block {
                        cell.fg = match self.cursor.cursor_color {
                            // Invert cursor if static background is close to the cell's
                            // background.
                            CellRgb::Rgb(col) if col.contrast(cell.bg) < MIN_CURSOR_CONTRAST => {
                                cell.bg
                            },
                            _ => self.cursor.text_color.color(cell.fg, cell.bg),
                        };
                    }

                    return Some(cell);
                } else {
                    // Handle cursor.
                    self.cursor.rendered = true;

                    let buffer_point = self.grid.visible_to_buffer(self.cursor.point);
                    let cell = Indexed {
                        inner: self.grid[buffer_point.line][buffer_point.col],
                        column: self.cursor.point.col,
                        line: self.cursor.point.line,
                    };

                    let mut cell = RenderableCell::new(self, cell);
                    cell.inner = RenderableCellContent::Cursor(self.cursor.key);

                    // Only apply static color if it isn't close to the cell's current
                    // background or refers to cell colors.
                    match self.cursor.cursor_color {

Review comment (suggestion):
```suggestion
                            // Apply cursor color, or invert the cursor if it has a fixed background close to the cell's background.
```

Code after:
        }
    }
}

impl<'a, C> Iterator for RenderableCellsIter<'a, C> {
    type Item = RenderableCell;

    /// Gets the next renderable cell.
    ///
    /// Skips empty (background) cells and applies any flags to the cell state
    /// (eg. invert fg and bg colors).
    #[inline]
    fn next(&mut self) -> Option<Self::Item> {
        loop {
            if self.cursor.point.line == self.inner.line()
                && self.cursor.point.col == self.inner.column()
            {
                if self.cursor.rendered {
                    // Handle cell below cursor.
                    let cell = self.inner.next()?;
                    let mut cell = RenderableCell::new(self, cell);

                    if self.cursor.key.style == CursorStyle::Block {
                        cell.fg = match self.cursor.cursor_color {
                            // Apply cursor color, or invert the cursor if it has a fixed background
                            // close to the cell's background.
                            CellRgb::Rgb(col) if col.contrast(cell.bg) < MIN_CURSOR_CONTRAST => {
                                cell.bg
                            },
                            _ => self.cursor.text_color.color(cell.fg, cell.bg),
                        };
                    }

                    return Some(cell);
                } else {
                    // Handle cursor.
                    self.cursor.rendered = true;

                    let buffer_point = self.grid.visible_to_buffer(self.cursor.point);
                    let cell = Indexed {
                        inner: self.grid[buffer_point.line][buffer_point.col],
                        column: self.cursor.point.col,
                        line: self.cursor.point.line,
                    };

                    let mut cell = RenderableCell::new(self, cell);
                    cell.inner = RenderableCellContent::Cursor(self.cursor.key);

                    // Apply cursor color, or invert the cursor if it has a fixed background close
                    // to the cell's background.
                    match self.cursor.cursor_color {