Documents / Issues / issue-ae38739a68d4
A narrow terminal cut the id column of every document table
Below about 120 columns the context, search and query tables shrank the id to an ellipsis, so the value docir get needs was no longer printed.
What is wrong¶
docir context, docir search and docir query print their hits as one Rich table, and
below about 120 columns Rich made every column narrower to fit, the id included. The id cell
was cut with an ellipsis: adr… at 60 columns, adr-449… at 80, adr-449f9e… at 100. The
id is the one value a reader carries to the next command, and docir get answers a cut one
with "no document with id", so the table could not be used to go from scanning to reading.
The graph and stale markers wrapped onto a second line under the id as well.
Every document table goes through render_document_list in
src/docir/entry_points/cli/rendering.py. The other tables (tag list, schema show,
bench) show no document ids, and check and lint print findings as lines that wrap.
How it showed¶
Acceptance testing of 0.30.4 reproduced it nine times, at 60, 80 and 100 columns. The piped JSON was never affected: the table exists only at a terminal.
Resolution¶
The table is fitted to the console before Rich lays it out. The id column is never wrapped or
shrunk, and its minimum width is the longest id it holds, so no prefix length is assumed.
The title, the description and the matched section wrap, each budgeted at 20 characters or
less. When the columns still do not fit, whole columns are left out in a fixed order:
score, sim, type, matched section, status, then description. The id and the title
are never left out. A dim line under the table names what was left out and says to widen the
terminal or pass --json.
At 60 columns that leaves the id and the title, at 80 the description as well, and at 100 the status too. The JSON output is unchanged.
Verification¶
TestADocumentTablePrintsEveryIdWhole in tests/entry_points/test_rendering.py renders a
table holding a hashed id, a sequential id and a longer schema-defined prefix on consoles 60,
80 and 100 columns wide. It asserts that every id appears whole with its markers, that no
line is wider than the console, that the title stays, and which columns were left out. The id
assertions failed at all three widths before the fix. docir context against this
repository's own store was run in pseudo-terminals of 60, 80 and 100 columns.