{"record":{"id":"e960193ea82706a5","repo":"zed-industries/zed","slug":"a-window-always-holds-at-least-one-workspace","errorCode":null,"errorMessage":"a window always holds at least one workspace","messagePattern":"a window always holds at least one workspace","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/workspace/src/multi_workspace.rs","lineNumber":665,"sourceCode":"    }\n\n    pub fn active_workspace_is_retained(&self) -> bool {\n        self.held[self.displayed_index()].pinned\n    }\n\n    /// The displayed workspace is the most recently activated row.\n    fn displayed_index(&self) -> usize {\n        self.held\n            .iter()\n            .enumerate()\n            .max_by_key(|(_, held)| held.activated_at)\n            .expect(\"a window always holds at least one workspace\")\n            .0\n    }\n\n    /// Ensures a project group exists for `key`, creating one if needed.\n    fn ensure_project_group_state(&mut self, key: ProjectGroupKey) {\n        if key.path_list().paths().is_empty() {\n            return;\n        }\n\n        if self.project_groups.iter().any(|group| group.key == key) {\n            return;\n        }\n\n        self.project_groups.insert(\n            0,\n            ProjectGroupState {\n                key,\n                expanded: true,\n            },\n        );\n    }\n\n    /// Transitions a project group from `old_key` to `new_key`.\n    ///","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/workspace/src/multi_workspace.rs#L647-L683","documentation":"displayed_index() asserts the held-workspace list is non-empty because a window always has at least one workspace; the list was empty, meaning all workspaces were removed without a replacement being added — a workspace lifecycle bug.","triggerScenarios":"Thrown at crates/workspace/src/multi_workspace.rs:665 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure a workspace is always added before/when the last one is dropped","Check retention logic so the final workspace is never unheld","Return Option<usize> and handle the empty case"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}