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

Code before:
            cell_width = cell_dimensions.0;
            cell_height = cell_dimensions.1;

            info!("Cell size: {} x {}", cell_width, cell_height);
        }

        let (mut width, mut height) = (self.size_info.width(), self.size_info.height());
        if let Some(dimensions) = pending_update.dimensions() {
            width = dimensions.width as f32;
            height = dimensions.height as f32;
        }

        let padding = config.window.padding(self.window.scale_factor as f32);

        let new_size = SizeInfo::new(
            width,
            height,
            cell_width,
            cell_height,
            padding.0,
            padding.1,
            config.window.dynamic_padding,
        );

        // Queue renderer update if terminal dimensions/padding changed.
        if new_size != self.size_info {
            let renderer_update = self.pending_renderer_update.get_or_insert(Default::default());
            renderer_update.resize = true;
        }

        self.size_info = new_size;

        // Update number of column/lines in the viewport.
        let message_bar_lines =
            message_buffer.message().map_or(0, |m| m.text(&self.size_info).len());
        let search_lines = usize::from(search_active);
        self.size_info.reserve_lines(message_bar_lines + search_lines);

        // Resize PTY.
        pty_resize_handle.on_resize(self.size_info.into());

        // Resize terminal.
        terminal.resize(self.size_info);
    }

    /// Update the state of the renderer.
    ///
    /// NOTE: The update to the renderer is split from the display update on purpose, since
    /// on some platforms, like Wayland, resize and other OpenGL operations must be performed
    /// right before rendering, otherwise they could lock the back buffer resulting in
    /// rendering with the buffer of old size.

Review comment (suggestion):
You should compare after reserve lines I think, since it mutates terminfo, so it could be the same here, but reserve lines make it different.

See `self.size_info.reserve_lines(message_bar_lines + search_lines);`, it also mutates the `self.size_info`.

Code after:
            cell_width = cell_dimensions.0;
            cell_height = cell_dimensions.1;

            info!("Cell size: {} x {}", cell_width, cell_height);
        }

        let (mut width, mut height) = (self.size_info.width(), self.size_info.height());
        if let Some(dimensions) = pending_update.dimensions() {
            width = dimensions.width as f32;
            height = dimensions.height as f32;
        }

        let padding = config.window.padding(self.window.scale_factor as f32);

        let mut new_size = SizeInfo::new(
            width,
            height,
            cell_width,
            cell_height,
            padding.0,
            padding.1,
            config.window.dynamic_padding,
        );

        // Update number of column/lines in the viewport.
        let message_bar_lines = message_buffer.message().map_or(0, |m| m.text(&new_size).len());
        let search_lines = usize::from(search_active);
        new_size.reserve_lines(message_bar_lines + search_lines);

        // Resize PTY.
        pty_resize_handle.on_resize(new_size.into());

        // Resize terminal.
        terminal.resize(new_size);

        // Queue renderer update if terminal dimensions/padding changed.
        if new_size != self.size_info {
            let renderer_update = self.pending_renderer_update.get_or_insert(Default::default());
            renderer_update.resize = true;
        }
        self.size_info = new_size;
    }

    /// Update the state of the renderer.
    ///
    /// NOTE: The update to the renderer is split from the display update on purpose, since
    /// on some platforms, like Wayland, resize and other OpenGL operations must be performed
    /// right before rendering, otherwise they could lock the back buffer resulting in
    /// rendering with the buffer of old size.
    ///
    /// This also resolves any flickering, since the resize is now synced with frame callbacks.