tui-cs/Terminal.Gui · warning · ArgumentException
0 length lines are not supported
Error message
0 length lines are not supported
What it means
Thrown by the private helper GetLineEndOnDiffAxis when a line's length is exactly zero. Zero-length lines have no extent on the differing axis, so endpoint computation is undefined. It is an ArgumentException. In normal Exclude flow, zero-length exclusion lines and zero-length collection lines are filtered out before this helper runs, so this guard is effectively an internal invariant that should be unreachable through public API use.
Source
Thrown at Terminal.Gui/Drawing/LineCanvas/StraightLineExtensions.cs:190
/// <summary>
/// <para>
/// Calculates the single digit point where a line ends on the differing axis i.e. the maximum (controlling for
/// negative lengths).
/// </para>
/// <para>
/// For lines with <see cref="Orientation.Horizontal"/> this is an x coordinate. For lines that are
/// <see cref="Orientation.Vertical"/> this is a y coordinate.
/// </para>
/// </summary>
/// <param name="start">Where the line starts</param>
/// <param name="length">Length of the line</param>
/// <param name="orientation">Orientation of the line</param>
/// <returns>The maximum x or y (whichever is differing) point on the line, controlling for negative lengths. </returns>
private static int GetLineEndOnDiffAxis (Point start, int length, Orientation orientation)
{
if (length == 0)
{
throw new ArgumentException (@"0 length lines are not supported", nameof (length));
}
int sub = length > 0 ? 1 : -1;
if (orientation == Orientation.Vertical)
{
// Points on line differ by y
return Math.Max (start.Y + length - sub, start.Y);
}
// Points on line differ by x
return Math.Max (start.X + length - sub, start.X);
}
/// <summary>
/// <para>
/// Calculates the single digit point where a line starts on the differing axis i.e. the minimum (controlling for
/// negative lengths).View on GitHub (pinned to 2e47b11478)
Solutions
- Do not create StraightLine objects with Length == 0; use Length >= 1 or omit the line.
- Filter zero-length lines from your collection before calling LineCanvas/Exclude.
- If hit unexpectedly, file a bug: the public API is supposed to guard this.
Example fix
// before
canvas.AddLine(new StraightLine(start, 0, Orientation.Horizontal, style));
// after
if (length > 0)
canvas.AddLine(new StraightLine(start, length, Orientation.Horizontal, style)); Defensive patterns
Strategy: validation
Validate before calling
lines = lines.Where(l => l.Length != 0);
Type guard
static bool HasNoZeroLengthLines(IEnumerable<StraightLine> lines) => lines.All(l => l.Length != 0);
Prevention
- Never add a zero-length StraightLine to a LineCanvas.
- Filter zero-length lines out of collections before line operations.
- If reached via public API, report it as an internal-invariant bug.
When it happens
Trigger: Directly causing a StraightLine with Length == 0 to reach endpoint computation. Under the public Exclude API this is guarded (length==0 returns early; collection lines with Length==0 are skipped), so it indicates either an internal bug or a future caller bypassing the guards.
Common situations: Constructing StraightLine instances with Length 0 and passing them into LineCanvas operations that compute endpoints; or a regression in the Exclude guard logic.
Related errors
- At least one color stop must be provided.
- Steps must be greater than 0.
- Number of steps must be N-1
- start must be greater than or equal to 0
- AdornmentView can only render to their Parent or Parent's Su
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/ce6bb97834f3da6e.
Report an issue: GitHub.