{"record":{"id":"ff69af264a163d74","repo":"spectreconsole/spectre.console","slug":"cannot-split-the-same-layout-twice","errorCode":null,"errorMessage":"Cannot split the same layout twice","messagePattern":"Cannot split the same layout twice","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Layout/Layout.cs","lineNumber":259,"sourceCode":"            }\n        }\n    }\n\n    private IEnumerable<Layout> GetChildren(bool visibleOnly = false)\n    {\n        return visibleOnly ? _children.Where(c => c.IsVisible) : _children;\n    }\n\n    private bool HasChildren(bool visibleOnly = false)\n    {\n        return visibleOnly ? _children.Any(c => c.IsVisible) : _children.Any();\n    }\n\n    private void Split(LayoutSplitter splitter, Layout[] layouts)\n    {\n        if (_children.Length > 0)\n        {\n            throw new InvalidOperationException(\"Cannot split the same layout twice\");\n        }\n\n        _splitter = splitter ?? throw new ArgumentNullException(nameof(splitter));\n        _children = layouts ?? throw new ArgumentNullException(nameof(layouts));\n    }\n\n    private Dictionary<Layout, LayoutRender> MakeRenderMap(RenderOptions options, int maxWidth)\n    {\n        var result = new Dictionary<Layout, LayoutRender>();\n\n        var renderWidth = maxWidth;\n        var renderHeight = options.Height ?? options.ConsoleSize.Height;\n        var regionMap = MakeRegionMap(maxWidth, renderHeight);\n\n        foreach (var (layout, region) in regionMap.Where(x => !x.Layout.HasChildren(visibleOnly: true)))\n        {\n            var segments = layout.Renderable.Render(options with { Height = region.Height }, region.Width);\n","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Layout/Layout.cs#L241-L277","documentation":"Thrown by the private Layout.Split method when the layout already has children. A layout can only be split once; calling SplitRows or the column split a second time is not permitted because the node is already subdivided.","triggerScenarios":"Calling SplitRows (or SplitColumns) twice on the same Layout instance, or splitting a layout that already received children.","commonSituations":"Reconfiguring a layout at runtime by re-splitting, or calling Split after a prior Split in initialization code.","solutions":["Split each layout node only once.","To restructure, create a fresh layout tree instead of re-splitting an existing node.","Remove the duplicate Split call."],"exampleFix":"// before\nlayout.SplitRows(new Layout(\"a\"), new Layout(\"b\"));\nlayout.SplitRows(new Layout(\"c\")); // throws\n\n// after\nvar layout = new Layout(\"root\");\nlayout.SplitRows(new Layout(\"a\"), new Layout(\"b\"));\n// do not split again; build a new tree if restructuring is needed","handlingStrategy":"validation","validationCode":"// Only call SplitRows/SplitColumns once per layout node.\n// Track split state in your own code if dynamic reconfiguration is needed.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split each node exactly once.","Build a new layout tree rather than re-splitting when restructuring."],"tags":["layout","invalid-operation","split","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}