zed-industries/zed · error

checked above

Error message

checked above

What it means

Companion expect to the 'old_selections isn't empty' guard in select_larger_syntax_node ('checked above'): the same zip of the last old and new selections assumes at least one prior selection existed when the selection-expansion was recorded. It fires when that earlier check is bypassed — e.g. a refactor moves or removes the early return — leaving an empty old_selections list to reach the history push.

Source

Thrown at crates/editor/src/selection.rs:754

                    goal: SelectionGoal::None,
                    reversed: selection.reversed,
                }
            })
            .collect::<Vec<_>>();

        if !selected_larger_node {
            return; // don't put this call in the history
        }

        // scroll based on transformation done to the last selection created by the user
        let (last_old, last_new) = old_selections
            .last()
            .zip(new_selections.last().cloned())
            .expect("old_selections isn't empty");

        let is_selection_reversed = if new_selections.len() == 1 {
            let should_be_reversed = last_old.start != last_new.start;
            new_selections.last_mut().expect("checked above").reversed = should_be_reversed;
            should_be_reversed
        } else {
            last_new.reversed
        };

        self.select_syntax_node_history.disable_clearing = true;
        self.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
            s.select(new_selections.clone());
        });
        self.select_syntax_node_history.disable_clearing = false;

        let start_row = last_new.start.to_display_point(&display_map).row().0;
        let end_row = last_new.end.to_display_point(&display_map).row().0;
        let selection_height = end_row - start_row + 1;
        let scroll_margin_rows = self.vertical_scroll_margin() as u32;

        let fits_on_the_screen = visible_row_count >= selection_height + scroll_margin_rows * 2;
        let scroll_behavior = if fits_on_the_screen {

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Replace the expect with an explicit if let Some((last_old, last_new)) = ...zip(...) and skip autoscroll when absent
  2. Keep the emptiness check adjacent to the use so 'checked above' cannot drift
  3. Add a test covering select_larger_syntax_node with no prior selections
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/editor/src/selection.rs:754 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/fa42f0b96a390b47. Report an issue: GitHub.