Repository: zellij-org/zellij
File: zellij-server/src/ui/overlay/mod.rs (Rust)

Code before:
    fn generate_overlay(&self, size: Size) -> Result<String> {
        match &self {
            OverlayType::Prompt(prompt) => prompt
                .generate_overlay(size)
                .context("failed to generate overlay for overlay type"),
        }
    }
}

/// Entrypoint from [`Screen`], which holds the context in which
/// the overlays are being rendered.
/// The most recent overlays draw over the previous overlays.
#[derive(Clone, Debug, Default)]
pub struct OverlayWindow {
    pub overlay_stack: Vec<Overlay>,
}

impl Overlayable for OverlayWindow {
    fn generate_overlay(&self, size: Size) -> Result<String> {
        let mut output = String::new();
        //let clear_display = "\u{1b}[2J";
        //output.push_str(&clear_display);
        for overlay in &self.overlay_stack {
            let vte_output = overlay
                .generate_overlay(size)
                .context("failed to generate overlay for overlay window")?;
            output.push_str(&vte_output);
        }
        Ok(output)
    }
}

impl Overlay {
    pub fn prompt_confirm(self) -> Option<Box<ServerInstruction>> {
        match self.overlay_type {
            OverlayType::Prompt(p) => p.confirm(),
        }
    }
    pub fn prompt_deny(self) -> Option<Box<ServerInstruction>> {
        match self.overlay_type {
            OverlayType::Prompt(p) => p.deny(),
        }
    }
}

impl Overlayable for Overlay {
    fn generate_overlay(&self, size: Size) -> Result<String> {
        self.overlay_type
            .generate_overlay(size)
            .context("failed to generate overlay for overlay")
    }

Review comment (bug):
```suggestion
                .context("failed to generate VTE output from overlay window")?;
```

Code after:
    fn generate_overlay(&self, size: Size) -> Result<String> {
        match &self {
            OverlayType::Prompt(prompt) => prompt
                .generate_overlay(size)
                .context("failed to generate VTE output from overlay type"),
        }
    }
}

/// Entrypoint from [`Screen`], which holds the context in which
/// the overlays are being rendered.
/// The most recent overlays draw over the previous overlays.
#[derive(Clone, Debug, Default)]
pub struct OverlayWindow {
    pub overlay_stack: Vec<Overlay>,
}

impl Overlayable for OverlayWindow {
    fn generate_overlay(&self, size: Size) -> Result<String> {
        let mut output = String::new();
        //let clear_display = "\u{1b}[2J";
        //output.push_str(&clear_display);
        for overlay in &self.overlay_stack {
            let vte_output = overlay
                .generate_overlay(size)
                .context("failed to generate VTE output from overlay window")?;
            output.push_str(&vte_output);
        }
        Ok(output)
    }
}

impl Overlay {
    pub fn prompt_confirm(self) -> Option<Box<ServerInstruction>> {
        match self.overlay_type {
            OverlayType::Prompt(p) => p.confirm(),
        }
    }
    pub fn prompt_deny(self) -> Option<Box<ServerInstruction>> {
        match self.overlay_type {
            OverlayType::Prompt(p) => p.deny(),
        }
    }
}

impl Overlayable for Overlay {
    fn generate_overlay(&self, size: Size) -> Result<String> {
        self.overlay_type
            .generate_overlay(size)
            .context("failed to generate VTE output from overlay")
    }