Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and `MarkupString.Pueblo`. The packages share one version and are released toget
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project
follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.22.1 — Unreleased

### Fixed

- A `Table` read as cards (linear, or too narrow for its columns) trims the spaces around each heading
before using it as a label, so a heading padded for its column, such as `"Idle "`, reads `Idle: 59s`
instead of `Idle : 59s`.

## 2.22.0 — Unreleased

### Added
Expand Down
10 changes: 10 additions & 0 deletions MarkupString.Tests/Layout/FieldsAndTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ public async Task Fields_Linear_ReadLabelThenValue()
=> await Assert.That(Lines(Sheet(Character[..2]) with { Columns = 2 }, 40, new LayoutContext { Linear = true }))
.IsEquivalentTo(new[] { "Sex: Male", "Species: Human" });

[Test]
public async Task Table_Linear_LabelsEachCellWithoutTheHeadingsPadding()
{
var table = new Table(
[new TableColumn(P("Player")), new TableColumn(P("Idle ")) { Alignment = Alignment.Right }],
[[new TextBlock(P("Mannaz")), new TextBlock(P("59s"))]]);

await Assert.That(Lines(table, 40, new LayoutContext { Linear = true })).IsEquivalentTo(new[] { "Player: Mannaz", "Idle: 59s" });
}

private static Tree Channels(TreeGuide guide) => new(
[
new TreeItem(P("Channels"),
Expand Down
3 changes: 2 additions & 1 deletion MarkupString/Layout/Blocks/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ private void DrawCards(LayoutContext context, int width, IList<MarkupText> lines
{
if (r > 0 && !context.Linear) lines.Add(MarkupText.Empty);
var row = rows[r];
cards.Draw(new Fields([.. Enumerable.Range(0, Columns.Length).Select(c => new Field(Columns[c].Header, Cell(row, c)))]), width, lines);
// A header's outer spaces line its column up with the next; as a label they would sit before the colon.
cards.Draw(new Fields([.. Enumerable.Range(0, Columns.Length).Select(c => new Field(Columns[c].Header.Trim(TrimType.TrimBoth), Cell(row, c)))]), width, lines);
}
}

Expand Down
Loading