{"record":{"id":"523d557e02e86220","repo":"zed-industries/zed","slug":"measurement-has-not-been-performed","errorCode":null,"errorMessage":"measurement has not been performed","messagePattern":"measurement has not been performed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/elements/text.rs","lineNumber":834,"sourceCode":"            line.paint(\n                line_origin,\n                line_height,\n                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;","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/elements/text.rs#L816-L852","documentation":"TextShapeRef::index_for_position requires measurement (layout) to have run; the element state is None because the text element's request_layout/measurement never executed before the call. Calling index_for_position before the element has been laid out and painted in the current frame panics.","triggerScenarios":"Thrown at crates/gpui/src/elements/text.rs:834 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only call index_for_position after the element completed request_layout/prepaint in this frame","Cache measured state across frames if hit-testing happens outside paint","Guard calls with an existence check on the element state instead of expecting"],"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"}