{"record":{"id":"261babad40d73cc1","repo":"zed-industries/zed","slug":"row-out-of-range","errorCode":null,"errorMessage":"row out of range","messagePattern":"row out of range","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/display_map/block_map.rs","lineNumber":2473,"sourceCode":"    }\n\n    #[ztracing::instrument(skip_all)]\n    pub(super) fn line_len(&self, row: BlockRow) -> u32 {\n        let (start, _, item) =\n            self.transforms\n                .find::<Dimensions<BlockRow, WrapRow>, _>((), &row, Bias::Right);\n        if let Some(transform) = item {\n            let Dimensions(output_start, input_start, _) = start;\n            let overshoot = row - output_start;\n            if transform.block.is_some() {\n                0\n            } else {\n                self.wrap_snapshot.line_len(input_start + overshoot)\n            }\n        } else if row == BlockRow(0) {\n            0\n        } else {\n            panic!(\"row out of range\");\n        }\n    }\n\n    #[ztracing::instrument(skip_all)]\n    pub(super) fn is_block_line(&self, row: BlockRow) -> bool {\n        let (_, _, item) = self.transforms.find::<BlockRow, _>((), &row, Bias::Right);\n        item.is_some_and(|t| t.block.is_some())\n    }\n\n    #[ztracing::instrument(skip_all)]\n    pub(super) fn is_folded_buffer_header(&self, row: BlockRow) -> bool {\n        let (_, _, item) = self.transforms.find::<BlockRow, _>((), &row, Bias::Right);\n        let Some(transform) = item else {\n            return false;\n        };\n        matches!(transform.block, Some(Block::FoldedBuffer { .. }))\n    }\n","sourceCodeStart":2455,"sourceCodeEnd":2491,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/display_map/block_map.rs#L2455-L2491","documentation":"BlockMapSnapshot::line_len(BlockRow) seeks the transform tree to find the wrap row for a given block row. If the seek finds no transform (the row lies past the end of the map) and the row is not row 0 of an empty map, the method panics 'row out of range'. It is an internal bounds invariant of the editor's display map: block rows must be within the snapshot's row range.","triggerScenarios":"Querying line_len with a BlockRow that is >= the snapshot's row count — usually a row computed against an older DisplaySnapshot after edits/blocks changed, or an off-by-one where row_count is passed instead of the last valid row.","commonSituations":"Editor code paths using stale rows after a concurrent edit; plugin or new feature code reusing rows across snapshot versions; regressions in display_map internals.","solutions":["Recompute the row against the current display/block snapshot before querying","Clamp the row to the snapshot maximum before calling: row = row.min(max_point().row())","If it reproduces with plain Zed usage, capture repro steps and report it — this is an internal invariant violation, not caller-configurable behavior"],"exampleFix":"// before\nlet len = block_snapshot.line_len(row); // row may be stale/out of range\n\n// after\nlet max_row = block_snapshot.max_point().row();\nlet len = block_snapshot.line_len(row.min(max_row));","handlingStrategy":"validation","validationCode":"let max_row = block_snapshot.max_point().row();\nlet row = row.min(max_row);\nlet len = block_snapshot.line_len(row);","typeGuard":"fn block_row_in_range(snapshot: &BlockMapSnapshot, row: BlockRow) -> bool {\n    row <= snapshot.max_point().row()\n}","tryCatchPattern":null,"preventionTips":["Never reuse rows across snapshots; recompute from the snapshot you query","Clamp externally derived rows to max_point() before display-map lookups","In editor code, treat this panic as a bug report: attach repro steps"],"tags":["zed","editor","display-map","block-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-14T00:17:10.932Z"}