Repository: helix-editor/helix
File: helix-term/src/ui/popup.rs (Rust)

Code before:
            }
        }
        // for some events, we want to process them but send ignore, specifically all input except
        // tab/enter/ctrl-k or whatever will confirm the selection/ ctrl-n/ctrl-p for scroll.
    }

    fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
        let RenderInfo {
            area,
            child_height,
            render_borders,
            is_menu,
        } = self.render_info(viewport, cx.editor);
        self.area = area;

        let max_offset = child_height.saturating_sub(area.height) as usize;
        let half_page_size = (area.height / 2) as usize;
        let scroll = max_offset.min(self.scroll_half_pages * half_page_size);
        if half_page_size > 0 {
            self.scroll_half_pages = scroll / half_page_size;
        }
        cx.scroll = Some(scroll);

        // clear area
        let background = if is_menu {
            // TODO: consisently style menu
            cx.editor
                .theme
                .try_get("ui.menu")
                .unwrap_or_else(|| cx.editor.theme.get("ui.text"))
        } else {
            cx.editor.theme.get("ui.popup")
        };
        surface.clear_with(area, background);

        let mut inner = area;
        if render_borders {
            inner = area.inner(&Margin::all(1));
            Widget::render(Block::default().borders(Borders::ALL), area, surface);
        }
        let border = usize::from(render_borders);

        self.contents.render(inner, surface, cx);

        // render scrollbar if contents do not fit
        if self.has_scrollbar {
            let win_height = (inner.height as usize).saturating_sub(2 * border);
            let len = (child_height as usize).saturating_sub(2 * border);
            let fits = len <= win_height;
            let scroll_style = cx.editor.theme.get("ui.menu.scroll");


Review comment (suggestion):
```suggestion
            // TODO: consistently style menu
```

Code after:
            }
        }
        // for some events, we want to process them but send ignore, specifically all input except
        // tab/enter/ctrl-k or whatever will confirm the selection/ ctrl-n/ctrl-p for scroll.
    }

    fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
        let RenderInfo {
            area,
            child_height,
            render_borders,
            is_menu,
        } = self.render_info(viewport, cx.editor);
        self.area = area;

        // clear area
        let background = if is_menu {
            // TODO: consistently style menu
            cx.editor
                .theme
                .try_get("ui.menu")
                .unwrap_or_else(|| cx.editor.theme.get("ui.text"))
        } else {
            cx.editor.theme.get("ui.popup")
        };
        surface.clear_with(area, background);

        let mut inner = area;
        if render_borders {
            inner = area.inner(&Margin::all(1));
            Widget::render(Block::default().borders(Borders::ALL), area, surface);
        }
        let border = usize::from(render_borders);

        let max_offset = child_height.saturating_sub(inner.height) as usize;
        let half_page_size = (inner.height / 2) as usize;
        let scroll = max_offset.min(self.scroll_half_pages * half_page_size);
        if half_page_size > 0 {
            self.scroll_half_pages = scroll / half_page_size;
        }
        cx.scroll = Some(scroll);
        self.contents.render(inner, surface, cx);

        // render scrollbar if contents do not fit
        if self.has_scrollbar {
            let win_height = inner.height as usize;
            let len = child_height as usize;
            let fits = len <= win_height;
            let scroll_style = cx.editor.theme.get("ui.menu.scroll");

            const fn div_ceil(a: usize, b: usize) -> usize {