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 <noreply@anthropic.com>
This commit is contained in:
1 parent
d08513aa69
commit
e1557f86e1
2 files changed
+21
-1
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user