{"record":{"id":"006a255189707728","repo":"zed-industries/zed","slug":"invalid-display-row","errorCode":null,"errorMessage":"invalid display row {}","messagePattern":"invalid display row (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/display_map/fold_map.rs","lineNumber":829,"sourceCode":"    pub fn len(&self) -> FoldOffset {\n        FoldOffset(self.transforms.summary().output.len)\n    }\n\n    #[ztracing::instrument(skip_all)]\n    pub fn line_len(&self, row: u32) -> u32 {\n        let line_start = FoldPoint::new(row, 0).to_offset(self).0;\n        let line_end = if row >= self.max_point().row() {\n            self.len().0\n        } else {\n            FoldPoint::new(row + 1, 0).to_offset(self).0 - 1\n        };\n        (line_end - line_start) as u32\n    }\n\n    #[ztracing::instrument(skip_all)]\n    pub fn row_infos(&self, start_row: u32) -> FoldRows<'_> {\n        if start_row > self.transforms.summary().output.lines.row {\n            panic!(\"invalid display row {}\", start_row);\n        }\n\n        let fold_point = FoldPoint::new(start_row, 0);\n        let mut cursor = self\n            .transforms\n            .cursor::<Dimensions<FoldPoint, InlayPoint>>(());\n        cursor.seek(&fold_point, Bias::Left);\n\n        let overshoot = fold_point.0 - cursor.start().0.0;\n        let inlay_point = InlayPoint(cursor.start().1.0 + overshoot);\n        let input_rows = self.inlay_snapshot.row_infos(inlay_point.row());\n\n        FoldRows {\n            fold_point,\n            input_rows,\n            cursor,\n        }\n    }","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/display_map/fold_map.rs#L811-L847","documentation":"FoldMapSnapshot::row_infos(start_row) iterates fold rows starting at a display row; it panics with 'invalid display row {}' when start_row exceeds the snapshot's total row count (transforms summary output lines). Note the check is `>`, so start_row equal to the row count is legal (empty iterator at the end); anything beyond is invalid.","triggerScenarios":"Calling row_infos (or editor APIs that delegate to it, like display_map row iteration) with a start row greater than the number of display rows — e.g. a row taken from a stale FoldSnapshot after folds or edits changed, or an unclamped loop bound from another snapshot.","commonSituations":"Rows cached from an earlier render pass reused after document edits; multi-snapshot code mixing buffer rows with display rows; internal regressions after fold changes.","solutions":["Derive start_row from the same snapshot you call row_infos on","Clamp before calling: start_row = start_row.min(snapshot.max_point().row())","If triggered inside Zed with no custom code, report the panic with the document/edit history — it indicates an internal invariant break"],"exampleFix":"// before\nlet infos = fold_snapshot.row_infos(start_row); // possibly > row count\n\n// after\nlet max_row = fold_snapshot.max_point().row();\nlet infos = fold_snapshot.row_infos(start_row.min(max_row));","handlingStrategy":"validation","validationCode":"let max_row = fold_snapshot.max_point().row();\nlet start = start_row.min(max_row + 1); // row == count is allowed (empty tail)\nlet infos = fold_snapshot.row_infos(start);","typeGuard":"fn fold_row_in_range(snapshot: &FoldSnapshot, row: u32) -> bool {\n    row <= snapshot.transforms_row_count() // i.e. summary().output.lines.row\n}","tryCatchPattern":null,"preventionTips":["Derive iteration bounds from the same fold snapshot being iterated","Clamp start rows after any await/refresh point where the snapshot may have changed","Report internal occurrences upstream with the document state that triggered them"],"tags":["zed","editor","display-map","fold-map","out-of-range","panic"],"backgroundTag":"index-out-of-bounds","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}