zed-industries/zed · error
Visible context menu should always render.
Error message
Visible context menu should always render.
What it means
An internal render invariant: during editor element paint, if context_menu_visible is true the code expects the context menu popover to produce an element and panics with 'Visible context menu should always render.' when layout returns none. It fires when visibility state and the actual menu element/handle get out of sync — e.g. the menu handle points to a menu that failed to build or was already dismissed while the visible flag still latched true.
Source
Thrown at crates/editor/src/element.rs:3970
right: -right_margin - MENU_GAP,
..Default::default()
});
let min_height = height_above_menu + min_menu_height + height_below_menu;
let max_height = height_above_menu + max_menu_height + height_below_menu;
let (laid_out_popovers, y_flipped) = self.layout_popovers_above_or_below_line(
target_position,
line_height,
min_height,
max_height,
context_menu_placement,
text_hitbox,
viewport_bounds,
window,
cx,
|height, max_width_for_stable_x, y_flipped, window, cx| {
// First layout the menu to get its size - others can be at least this wide.
let context_menu = if context_menu_visible {
let menu_height = if y_flipped {
height - height_below_menu
} else {
height - height_above_menu
};
let mut element = self
.render_context_menu(line_height, menu_height, window, cx)
.expect("Visible context menu should always render.");
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
Some((CursorPopoverType::CodeContextMenu, element, size))
} else {
None
};
let min_width = context_menu
.as_ref()
.map_or(px(0.), |(_, _, size)| size.width);
let max_width = max_width_for_stable_x.max(
context_menuView on GitHub (pinned to 9d272b0363)
Solutions
- Replace the expect with a graceful skip: if the menu element is missing, render as if the menu were not visible
- Clear context_menu_visible whenever the popover handle reports no active menu
- Drive visibility from the same popover handle query used to fetch the element, so state cannot diverge
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/editor/src/element.rs:3893 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/fe60883dea98d1dd.
Report an issue: GitHub.