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

Code before:
        let vi_mode = terminal.mode().contains(TermMode::VI);
        let vi_cursor_point = if vi_mode { Some(terminal.vi_mode_cursor.point) } else { None };

        // Add damage from the terminal.
        if self.collect_damage() {
            match terminal.damage() {
                TermDamage::Full => self.damage_tracker.frame().mark_fully_damaged(),
                TermDamage::Partial(damaged_lines) => {
                    for damage in damaged_lines {
                        self.damage_tracker.frame().damage_line(damage);
                    }
                },
            }
            terminal.reset_damage();
        }

        // Invalidate highlighted hints if grid has changed.
        let mut filter_highlight = |highlight: &mut Option<HighlightedHint>| match highlight {
            Some(hl) if !hl.has_valid_range(&mut terminal) => {
                self.window.set_mouse_cursor(CursorIcon::Default);
                *highlight = None;
            },
            _ => (),
        };
        filter_highlight(&mut self.vi_highlighted_hint);
        filter_highlight(&mut self.highlighted_hint);

        // Drop terminal as early as possible to free lock.
        drop(terminal);

        // Add damage from alacritty's UI elements overlapping terminal.
        if self.collect_damage() {
            let requires_full_damage = self.visual_bell.intensity() != 0.
                || self.hint_state.active()
                || search_state.regex().is_some();

            if requires_full_damage {
                self.damage_tracker.frame().mark_fully_damaged();
                self.damage_tracker.next_frame().mark_fully_damaged();
            }

            let vi_cursor_viewport_point =
                vi_cursor_point.and_then(|cursor| point_to_viewport(display_offset, cursor));

            self.damage_tracker.damage_vi_cursor(vi_cursor_viewport_point);
            self.damage_tracker.damage_selection(selection_range, display_offset);
        }

        // Make sure this window's OpenGL context is active.
        self.make_current();


Review comment (bug):
Perhaps I'm thinking about this wrong because I frankly forget the distinction between `highlighted_hint` and `vi_highlighted_hint` exactly, but if there are two overlapping highlights, wouldn't we only want to change the cursor if both are invalid?

Code after:
        let vi_cursor_point = if vi_mode { Some(terminal.vi_mode_cursor.point) } else { None };

        // Add damage from the terminal.
        match terminal.damage() {
            TermDamage::Full => self.damage_tracker.frame().mark_fully_damaged(),
            TermDamage::Partial(damaged_lines) => {
                for damage in damaged_lines {
                    self.damage_tracker.frame().damage_line(damage);
                }
            },
        }
        terminal.reset_damage();

        // Drop terminal as early as possible to free lock.
        drop(terminal);

        // Invalidate highlighted hints if grid has changed.
        self.validate_hints(display_offset);

        // Add damage from alacritty's UI elements overlapping terminal.

        let requires_full_damage = self.visual_bell.intensity() != 0.
            || self.hint_state.active()
            || search_state.regex().is_some();
        if requires_full_damage {
            self.damage_tracker.frame().mark_fully_damaged();
            self.damage_tracker.next_frame().mark_fully_damaged();
        }

        let vi_cursor_viewport_point =
            vi_cursor_point.and_then(|cursor| term::point_to_viewport(display_offset, cursor));
        self.damage_tracker.damage_vi_cursor(vi_cursor_viewport_point);
        self.damage_tracker.damage_selection(selection_range, display_offset);

        // Make sure this window's OpenGL context is active.
        self.make_current();

        self.renderer.clear(background_color, config.window_opacity());
        let mut lines = RenderLines::new();

        // Optimize loop hint comparator.
        let has_highlighted_hint =
            self.highlighted_hint.is_some() || self.vi_highlighted_hint.is_some();

        // Draw grid.
        {
            let _sampler = self.meter.sampler();

            // Ensure macOS hasn't reset our viewport.
            #[cfg(target_os = "macos")]
            self.renderer.set_viewport(&size_info);