zed-industries/zed · error

This index will always exist

Error message

This index will always exist

What it means

Internal assertion in stack_frame_list.rs while scrolling to the selected stack frame after toggling a frame filter: the selected index is expected to always exist in the filtered list at that point. Firing indicates a filter/index desynchronization bug in the list state.

Source

Thrown at crates/debugger_ui/src/session/running/stack_frame_list.rs:887

                StackFrameFilter::OnlyUserFrames => {
                    self.list_state.reset(self.filter_entries_indices.len());
                    if !self
                        .selected_ix
                        .map(|ix| self.filter_entries_indices.contains(&ix))
                        .unwrap_or_default()
                    {
                        self.selected_ix = None;
                    }
                }
            }

            if let Some(ix) = self.selected_ix {
                let scroll_to = match self.list_filter {
                    StackFrameFilter::All => ix,
                    StackFrameFilter::OnlyUserFrames => self
                        .filter_entries_indices
                        .binary_search_by_key(&ix, |ix| *ix)
                        .expect("This index will always exist"),
                };
                self.list_state.scroll_to_reveal_item(scroll_to);
            }

            cx.emit(StackFrameListEvent::BuiltEntries);
            cx.notify();
        }
    }

    fn render_list(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        div().p_1().size_full().child(
            list(
                self.list_state.clone(),
                cx.processor(|this, ix, _window, cx| this.render_entry(ix, cx)),
            )
            .size_full(),
        )
    }

View on GitHub (pinned to f4178619ac)

Solutions

  1. Reset the selected frame index after toggling the filter (the code already attempts this)
  2. File a bug with the debugger session and filter state that triggered it
  3. Toggle the filter again or restart the debug session to resync indices
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/debugger_ui/src/session/running/stack_frame_list.rs:887 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/2b1bee1abed8d0b1. Report an issue: GitHub.