Repository: zellij-org/zellij
File: zellij-server/src/panes/grid.rs (Rust)

Code before:
                }
            }
        }
        if self.ring_bell {
            let ring_bell = '\u{7}';
            raw_vte_output.push(ring_bell);
            self.ring_bell = false;
        }
        return Ok(Some((
            character_chunks,
            Some(raw_vte_output),
            sixel_image_chunks,
        )));
    }
    pub fn cursor_coordinates(&self) -> Option<(usize, usize)> {
        if self.cursor_is_hidden {
            None
        } else {
            Some((self.cursor.x, self.cursor.y))
        }
    }
    /// Clears all buffers with text
    pub fn clear_screen(&mut self) {
        self.lines_above = Default::default();
        self.lines_below = Default::default();
        self.viewport = Default::default();
    }
    /// Dumps all lines above terminal vieport and the viewport itself to a string
    pub fn dump_screen(&mut self, full: bool) -> String {
        let viewport: String = dump_screen!(self.viewport);
        if !full {
            return viewport;
        }
        let mut scrollback: String = dump_screen!(self.lines_above);
        if !scrollback.is_empty() {
            scrollback.push('\n');
        }
        scrollback.push_str(&viewport);
        scrollback
    }
    pub fn move_viewport_up(&mut self, count: usize) {
        for _ in 0..count {
            self.scroll_up_one_line();
        }
        self.output_buffer.update_all_lines();
    }
    pub fn move_viewport_down(&mut self, count: usize) {
        for _ in 0..count {
            self.scroll_down_one_line();
        }
        self.output_buffer.update_all_lines();

Review comment (suggestion):
Let's add a conditional here so that we don't do this if `alternate_screen` is `Some`. This happens when eg. programs running in the terminal switch to full screen (eg. `htop` and friends - also Zellij itself). I think in such cases we really don't want to do this. We can add a log if that happens.

Code after:
                }
            }
        }
        if self.ring_bell {
            let ring_bell = '\u{7}';
            raw_vte_output.push(ring_bell);
            self.ring_bell = false;
        }
        return Ok(Some((
            character_chunks,
            Some(raw_vte_output),
            sixel_image_chunks,
        )));
    }
    pub fn cursor_coordinates(&self) -> Option<(usize, usize)> {
        if self.cursor_is_hidden {
            None
        } else {
            Some((self.cursor.x, self.cursor.y))
        }
    }
    /// Clears all buffers with text for a current screen
    pub fn clear_screen(&mut self) {
        if self.alternate_screen_state.is_some() {
            log::warn!("Tried to clear pane with alternate_screen_state");
            return;
        }
        self.reset_terminal_state();
        self.mark_for_rerender();
    }
    /// Dumps all lines above terminal vieport and the viewport itself to a string
    pub fn dump_screen(&mut self, full: bool) -> String {
        let viewport: String = dump_screen!(self.viewport);
        if !full {
            return viewport;
        }
        let mut scrollback: String = dump_screen!(self.lines_above);
        if !scrollback.is_empty() {
            scrollback.push('\n');
        }
        scrollback.push_str(&viewport);
        scrollback
    }
    pub fn move_viewport_up(&mut self, count: usize) {
        for _ in 0..count {
            self.scroll_up_one_line();
        }
        self.output_buffer.update_all_lines();
    }
    pub fn move_viewport_down(&mut self, count: usize) {
        for _ in 0..count {