{"record":{"id":"af63da4eb7bc2f8b","repo":"zed-industries/zed","slug":"compute-indents-fn-is-required-for-uniformlistdeco","errorCode":null,"errorMessage":"compute_indents_fn is required for UniformListDecoration","messagePattern":"compute_indents_fn is required for UniformListDecoration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ui/src/components/indent_guides.rs","lineNumber":229,"sourceCode":"        fn compute(\n            &self,\n            mut visible_range: Range<usize>,\n            bounds: Bounds<Pixels>,\n            _scroll_offset: Point<Pixels>,\n            item_height: Pixels,\n            item_count: usize,\n            window: &mut Window,\n            cx: &mut App,\n        ) -> AnyElement {\n            let includes_trailing_indent = visible_range.end < item_count;\n            // Check if we have entries after the visible range,\n            // if so extend the visible range so we can fetch a trailing indent,\n            // which is needed to compute indent guides correctly.\n            if includes_trailing_indent {\n                visible_range.end += 1;\n            }\n            let Some(ref compute_indents_fn) = self.compute_indents_fn else {\n                panic!(\"compute_indents_fn is required for UniformListDecoration\");\n            };\n            let visible_entries = &compute_indents_fn(visible_range.clone(), window, cx);\n            let indent_guides = compute_indent_guides(\n                visible_entries,\n                visible_range.start,\n                includes_trailing_indent,\n            );\n            self.render_from_layout(indent_guides, bounds, item_height, window, cx)\n        }\n    }\n}\n\n/// Implements the necessary functionality for rendering indent guides inside a sticky items.\nmod sticky_items {\n    use crate::StickyItemsDecoration;\n\n    use super::*;\n","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/ui/src/components/indent_guides.rs#L211-L247","documentation":"ui's UniformListDecoration draws indent guides over a GPUI uniform list by computing visible entries' indents through a caller-supplied closure (compute_indents_fn). The paint path requires that closure and panics on first paint without it (crates/ui/src/components/indent_guides.rs:229). The builder method with_compute_indents_fn (crates/ui/src/components/indent_guides.rs:84) exists precisely to install it.","triggerScenarios":"Constructing a UniformListDecoration (indent guides for a uniform-list component such as a tree or outline) without calling .with_compute_indents_fn(view_entity, closure), then letting the element render.","commonSituations":"Adding indent guides to a new uniform-list surface from an example that omits the closure; refactors dropping the builder call; using the uniform-list decoration where the plain element-iterator variant was intended.","solutions":["Call .with_compute_indents_fn(entity, closure) on the decoration before it renders; the closure receives the visible Range<usize> plus window/cx and returns the indents for those entries.","If you cannot supply indents, use the non-uniform decoration variant or skip the decoration entirely.","Harden the API: require the closure at construction (or debug_assert in the builder) so misuse fails at build time, not paint time."],"exampleFix":"// before\nlet decoration = IndentGuides::uniform_list_decoration(); // no compute fn\n\n// after\ndecoration.with_compute_indents_fn(entity, |this, visible_range: Range<usize>, _window, _cx| {\n    this.visible_indents(visible_range)\n})","handlingStrategy":"validation","validationCode":"// install the required closure before the element can paint\nlet decoration = decoration.with_compute_indents_fn(entity, |this, range: Range<usize>, _window, _cx| {\n    this.indents_for_range(range)\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair UniformListDecoration construction with with_compute_indents_fn.","Use the plain decoration variant when you cannot compute indents.","Fail fast at construction: require the closure in the API rather than panicking at paint time."],"tags":["gpui","ui","indent-guides","uniform-list","missing-callback","panic","zed"],"backgroundTag":"missing-required-callback","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"}