From e1557f86e10fdfc592fa3edf7268a83f766e2976 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Tue, 3 Nov 2026 17:44:02 -0500 Subject: [PATCH] The PLACE sort triangle sits next to its label A text lane padded its label to the lane width before the triangle, so the triangle landed at the far end of the wide PLACE lane, often past the screen edge. The label is now unpadded, as NAME's is; the columns do not move. Co-Authored-By: Claude Opus 5.5 --- meshterm/ui/contactlist.py | 5 ++++- tests/test_contact_places.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/meshterm/ui/contactlist.py b/meshterm/ui/contactlist.py index df7bcb1..8acd6e2 100644 --- a/meshterm/ui/contactlist.py +++ b/meshterm/ui/contactlist.py @@ -360,8 +360,11 @@ def _header( # A label aligned to the right, above a value aligned to the right. Thus the header # of a narrow field is where its digits will be (``PKTS`` above a 5-cell count), not # to the left of them. A text lane is the other way: on the left, as its values are. + # Its label is not padded, so the triangle comes directly after the word, as for + # ``NAME``. A padded label put the triangle at the far end of a wide lane, where the + # user did not see it, or past the edge of the screen. if lane.kind == "text": - column(header, _pad_cells(lane.label, lane.width), lane.column, lane.width) + column(header, lane.label, lane.column, lane.width) else: column(header, f"{lane.label:>{lane.width}}", lane.column, lane.width) column(header, "KEY", "hash", 3, last=True) diff --git a/tests/test_contact_places.py b/tests/test_contact_places.py index 7177742..062ae0d 100644 --- a/tests/test_contact_places.py +++ b/tests/test_contact_places.py @@ -8,6 +8,7 @@ that no database and no network are necessary. from __future__ import annotations +import dataclasses import re from rich.cells import cell_len @@ -177,6 +178,22 @@ def test_place_is_sortable() -> None: assert _names(screen) == ["Homestead", "Carl", "Alice", "Bob"] +def test_place_sort_triangle_is_next_to_the_label() -> None: + """The triangle comes directly after ``PLACE``, not at the far end of the wide lane. + + The sort must not move a column: ``KEY`` stays above the keys in both states. + """ + from meshterm.ui.contactlist import _GAP, _header + + lanes = (dataclasses.replace(PLACE_LANE, width=30),) + for sort in ("place", "name"): + header = _header(10, _sort(sort), lanes).plain + if sort == "place": + assert "PLACE ▲" in header + # The pointer and the type glyph (4), the name lane, the place lane, each with its gap. + assert header.index("KEY") == 4 + (10 + _GAP) + (30 + _GAP) + + def test_ctrl_arrows_reach_the_place_column() -> None: """Ctrl+→ goes name, heard, packets, place, hash.""" screen = _screen()