{"record":{"id":"57b864d1c18aefeb","repo":"zed-industries/zed","slug":"prepaint-has-not-been-performed","errorCode":null,"errorMessage":"prepaint has not been performed","messagePattern":"prepaint has not been performed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/elements/text.rs","lineNumber":837,"sourceCode":"                text_style.text_align,\n                Some(bounds),\n                window,\n                cx,\n            )\n            .log_err();\n            line_origin.y += line.size(line_height).height;\n        }\n    }\n\n    /// Get the byte index into the input of the pixel position.\n    pub fn index_for_position(&self, mut position: Point<Pixels>) -> Result<usize, usize> {\n        let element_state = self.0.borrow();\n        let element_state = element_state\n            .as_ref()\n            .expect(\"measurement has not been performed\");\n        let bounds = element_state\n            .bounds\n            .expect(\"prepaint has not been performed\");\n\n        if position.y < bounds.top() {\n            return Err(0);\n        }\n\n        let line_height = element_state.line_height;\n        let mut line_origin = bounds.origin;\n        let mut line_start_ix = 0;\n        for line in &element_state.lines {\n            let line_bottom = line_origin.y + line.size(line_height).height;\n            if position.y > line_bottom {\n                line_origin.y = line_bottom;\n                line_start_ix += line.len() + 1;\n            } else {\n                let position_within_line = position - line_origin;\n                match line.index_for_position(position_within_line, line_height) {\n                    Ok(index_within_line) => return Ok(line_start_ix + index_within_line),\n                    Err(index_within_line) => return Err(line_start_ix + index_within_line),","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/elements/text.rs#L819-L855","documentation":"The sibling expect in index_for_position: measurement exists but bounds were not filled, meaning prepaint never ran for the text element before index_for_position was called. The position-to-index lookup depends on prepaint-computed geometry, so calling it between layout and prepaint panics.","triggerScenarios":"Thrown at crates/gpui/src/elements/text.rs:837 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call index_for_position only after prepaint has completed for the current frame","Store prepaint bounds in element state during prepaint and verify presence","Return an error/Option instead of expecting when geometry is unavailable"],"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-14T05:17:10.506Z"}