{"record":{"id":"1ef2da8eaa8d3bd5","repo":"slint-ui/slint","slug":"line-limit-cut-returns-an-existing-line-index","errorCode":null,"errorMessage":"line_limit_cut returns an existing line index","messagePattern":"line_limit_cut returns an existing line index","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/core/textlayout/sharedparley/layout.rs","lineNumber":221,"sourceCode":"                    .map(|line| {\n                        let metrics = line.metrics();\n                        PhysicalLength::new(metrics.inline_min_coord + metrics.advance)\n                    })\n                    .fold(PhysicalLength::zero(), PhysicalLength::max),\n                _ => PhysicalLength::new(p.layout.full_width()),\n            }\n        })\n        .fold(PhysicalLength::zero(), PhysicalLength::max);\n    // With an active line limit, the height only extends to the bottom of the last kept line, so\n    // that the preferred height and vertical alignment are based on what is actually shown.\n    let height = match line_limit_cut {\n        Some((last_paragraph, last_line)) => {\n            let para = &paragraphs[last_paragraph];\n            let line = para\n                .layout\n                .lines()\n                .nth(last_line)\n                .expect(\"line_limit_cut returns an existing line index\");\n            para.y + PhysicalLength::new(line.metrics().block_max_coord)\n        }\n        None => paragraphs\n            .last()\n            .map_or(PhysicalLength::zero(), |p| p.y + PhysicalLength::new(p.layout.height())),\n    };\n\n    let y_offset = vertical_offset(max_physical_height, options.vertical_align, height);\n\n    Layout {\n        paragraphs,\n        y_offset,\n        elision_info,\n        max_width,\n        height,\n        max_physical_height,\n        line_limit_cut,\n        line_breaking_inputs: inputs,","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/core/textlayout/sharedparley/layout.rs#L203-L239","documentation":"In the shared Parley text layout, the `line_limit_cut` bookkeeping (the paragraph/line index where text was cut by a line-limit) is expected to always refer to an existing line in the paragraph's laid-out lines. `lines().nth(last_line).expect(...)` panics if the recorded index is stale — i.e. the internal invariant between the cut computation and the final parley layout broke.","triggerScenarios":"Rendering a Text element with a line limit (max height / `wrap` with vertical truncation) through the Parley-based (femtovg/skia) renderer when the cached cut index no longer matches the relaid-out paragraph lines.","commonSituations":"Text elements with `overflow: elide`/height-constrained text under dynamic font loading, font-size changes, or resize races where the layout is recomputed but the cut index is not; generally indicates a runtime bug rather than user error.","solutions":["Reproduce with a minimal .slint file and file an upstream bug (this is an internal invariant failure)","Update/patch Slint — the fix is usually in the text layout's line-limit recomputation","As a workaround, avoid combining line limits with dynamic font/size changes until fixed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// internal panic, not caller-recoverable; only a global guard helps\nstd::panic::catch_unwind(AssertUnwindSafe(|| draw_text(...))).unwrap_or_else(|_| default_text_render());","preventionTips":["Update Slint to the latest patch release (text-layout bugs are often fixed quickly)","Avoid rapidly changing line limits/font metrics on the same Text element in flight","Reproduce with a minimal case and report upstream with the .slint file"],"tags":["rust","panic","text-layout","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}