tui-cs/Terminal.Gui · critical · LayoutException
ComputedLayout for "{superView}": "{from}" linked with "{to}
Error message
ComputedLayout for "{superView}": "{from}" linked with "{to}" was not found. Did you forget to add it to {superView}? What it means
During the layout topological sort, a Pos/Dim referenced another view (e.g. Pos.Left(someView)) that is not present in the same SuperView hierarchy. The layout engine cannot position a view relative to one it does not know about, so it throws with a 'did you forget to add it' hint.
Source
Thrown at Terminal.Gui/ViewBase/View.Layout.cs:1256
}
// if 'to' is not yet added to the result, add it
if (result.Find (v => v == to) is null)
{
result.Add (to);
}
// remove from edge
edges.Remove ((from, to));
}
else if (from != superView?.GetTopSuperView (to, from) && !ReferenceEquals (from, to))
{
if (ReferenceEquals (from.SuperView, to))
{
throw new LayoutException ($"ComputedLayout for \"{superView}\": \"{to}\" " + $"references a SubView (\"{from}\").");
}
throw new LayoutException ($"ComputedLayout for \"{superView}\": \"{from}\" "
+ $"linked with \"{to}\" was not found. Did you forget to add it to {superView}?");
}
}
// return L (a topologically sorted order)
return result;
} // TopologicalSort
#endregion Topological Sort
#region Utilities
/// <summary>
/// Gets the size of the SuperView's content (nominally the same as
/// the SuperView's <see cref="GetContentSize ()"/>) or the screen size if there's no SuperView.
/// </summary>
/// <remarks>
/// This method provides fallback logic to ensure that a size is always returned, even if the SuperView is not set orView on GitHub (pinned to 2e47b11478)
Solutions
- Add both views to the same SuperView before relying on relative Pos/Dim.
- If a referenced view was removed, update the Pos to an Absolute or to the correct sibling.
- Check the from/to names in the message to identify the missing view.
Example fix
// before var a = new View(); var b = new View(); a.X = Pos.Right(b); // b not in hierarchy // after container.Add(a, b); a.X = Pos.Right(b);
Defensive patterns
Strategy: validation
Validate before calling
if (other.SuperView is null || !InternalSubViews.Contains(other))
Add(other); // or fix the reference
view.X = Pos.Right(other); Type guard
static bool AreInSameHierarchy (View a, View b) =>
a.SuperView is not null && a.SuperView == b.SuperView; Prevention
- Add both views to the same SuperView before using relative Pos.
- Avoid stale references after Remove().
- Use Absolute Pos if a referenced view may be absent.
When it happens
Trigger: view.X = Pos.Right(otherView) where otherView was never Add()ed to the same SuperView (or any SuperView); otherView was removed before layout; otherView belongs to a different container.
Common situations: Creating a view and setting relative positions before adding either view to a container; moving a view between containers but leaving stale Pos references; referencing a view from a different dialog/window.
Related errors
- ComputedLayout for "{superView}": "{to}" references a SubVie
- Target
- X cannot be null
- Y cannot be null
- The Viewport of an AdornmentView cannot be modified.
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/db9772349662f21a.
Report an issue: GitHub.