Skip to content

getDisplayValue() gives incorrect widths for collections #2806

@midichef

Description

@midichef

Small description
For cells that have dict/list/tuple contents, getDisplayValue() produces unexpected results that depend on the column width.

Steps to reproduce
echo '{"string": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "list": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}' |vd -f jsonl

Expected result
There are a variety of anomalies with the list column.

  1. I would expect both columns to be equally wide. But the second column, holding a list, is only wide enough to fit its name list.
  2. In a wide window, resizing a narrow list column with _ causes it to repeatedly increase its width. Each time it more than doubles its width, to 2*col.width+2, until it reaches about half the window width and can no longer double.
  3. syscopy results are truncated for list cells, but not string cells. For example, start by narrowing the string column to width 6 with z_ to match the list column. zY on string takes the full cell contents: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], but on the too-narrow list column it takes only [10] 1; 2; …. The difference in truncation is surprising. And the width of that truncated value is surprising too. It is actually wider than the value shown on screen, which is [10]….

Configuration
Anomaly #1 happens in visidata 3.2 but not 3.1.1 due to d1fb235.
Anomaly #2 is a longstanding visidata behavior.
Anomaly #3 is longstanding too.

Additional context
The problem behavior here is for dict/list/tuple columns. It manifests in a variety of ways. I'll use this as a central thread for discussing the getDisplayValue width-related behavior. And I'll make separate PRs that address the different manifestations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions