Repository: alacritty/alacritty
File: alacritty/src/window_context.rs (Rust)

Code before:
            );
        }

        if self.dirty || self.mouse.hint_highlight_dirty {
            self.dirty |= self.display.update_highlighted_hints(
                &terminal,
                config,
                &self.mouse,
                self.modifiers,
            );
            self.mouse.hint_highlight_dirty = false;
        }

        // Skip rendering on Wayland until we get frame event from compositor.
        #[cfg(not(any(target_os = "macos", windows)))]
        if !self.display.is_x11 && !self.display.window.should_draw.load(Ordering::Relaxed) {
            return;
        }

        if self.dirty {
            // Force the display to process any pending display update.
            self.display.process_renderer_update();

            // XXX it seems like on Wayland when creating a new window the buffer of the old window
            // may lock leading to resize not being honored, so ask for one more frame to draw in
            // that particular case.
            #[cfg(not(any(target_os = "macos", windows)))]
            if !self.display.is_x11 && mem::take(&mut self.redraw_next) {
                self.display.window.request_redraw();
            }

            self.dirty = false;

            // Request immediate re-draw if visual bell animation is not finished yet.
            if !self.display.visual_bell.completed() {
                self.display.window.request_redraw();
            }

            // Redraw screen.
            self.display.draw(terminal, &self.message_buffer, config, &self.search_state);
        }
    }

    /// ID of this terminal context.
    pub fn id(&self) -> WindowId {
        self.display.window.id()
    }

    /// Write the ref test results to the disk.
    pub fn write_ref_test_results(&self) {
        // Dump grid state.

Review comment (suggestion):
```suggestion
            // XXX: On Wayland when creating a new window the buffer of the old window
            // may lock leading to resize not being honored, so ask for one more frame to draw in
            // that particular case.
```

We should be certain, not guessing.

Code after:
            self.dirty |= self.display.update_highlighted_hints(
                &terminal,
                config,
                &self.mouse,
                self.modifiers,
            );
            self.mouse.hint_highlight_dirty = false;
        }

        // Skip rendering on Wayland until we get frame event from compositor.
        #[cfg(not(any(target_os = "macos", windows)))]
        if !self.display.is_x11 && !self.display.window.should_draw.load(Ordering::Relaxed) {
            return;
        }

        if self.dirty {
            // Force the display to process any pending display update.
            self.display.process_renderer_update();

            self.dirty = false;

            // Request immediate re-draw if visual bell animation is not finished yet.
            if !self.display.visual_bell.completed() {
                self.display.window.request_redraw();
            }

            // Redraw screen.
            self.display.draw(terminal, &self.message_buffer, config, &self.search_state);
        }
    }

    /// ID of this terminal context.
    pub fn id(&self) -> WindowId {
        self.display.window.id()
    }

    /// Write the ref test results to the disk.
    pub fn write_ref_test_results(&self) {
        // Dump grid state.
        let mut grid = self.terminal.lock().grid().clone();
        grid.initialize_all();
        grid.truncate();

        let serialized_grid = json::to_string(&grid).expect("serialize grid");

        let size_info = &self.display.size_info;
        let size = TermSize::new(size_info.columns(), size_info.screen_lines());
        let serialized_size = json::to_string(&size).expect("serialize size");

        let serialized_config = format!("{{\"history_size\":{}}}", grid.history_size());