Skip to content

fix(picker): align datetime column consistently in time-based pickers#413

Closed
hermandavid wants to merge 1 commit into
sudo-tee:mainfrom
hermandavid:fix/picker-datetime-alignment
Closed

fix(picker): align datetime column consistently in time-based pickers#413
hermandavid wants to merge 1 commit into
sudo-tee:mainfrom
hermandavid:fix/picker-datetime-alignment

Conversation

@hermandavid

Copy link
Copy Markdown
Contributor

Issue

The time column in session and timeline pickers was sized from each item's own timestamp, so recent sessions showing 10:35 and older ones showing 09 Jun 2024 10:35 had different column widths per row — datetimes were misaligned and older entries overflowed the visible pane with FZF picker.

Solution

The time column is now sized from the widest timestamp in the current item list, computed once when the picker opens. If all sessions are from today the column is compact; if older sessions are present it expands to fit. On picker reopen the width recomputes from the then-current list.

Primarily targets fzf-lua. The column width and separator fixes apply to all backends.

Tested with fzf-lua, Snacks, and Telescope.

The time column in session and timeline pickers had two alignment
issues causing the datetime to render partially or fully off-screen,
especially when a preview pane was active.

Per-item variable width: each row computed its own time column width
from format_time(timestamp), producing different widths for same-day
(e.g. '10:35') vs older entries (e.g. '09 Jun 2024 10:35'). Fixed by
using format_time(0) to derive the maximum column width from the
longest possible output (different-year format). Shorter time strings
are right-padded within the fixed column.

Separator double-counting: the +1 in time_width and debug_width was
intended for the separator between parts, but to_string() and
to_formatted_text() already add their own separators. This caused rows
to exceed item_width by 1-2 chars, pushing the time column past the
visible pane edge. Fixed by accounting for separators explicitly.

Unreliable fzf width_callback: the start:+transform callback read
FZF_PREVIEW_COLUMNS to compute list pane width, but this env var could
be 0 or absent at fzf start time. When missing, format_width fell back
to the full window width, formatting items much wider than the visible
list pane. Removed this mechanism in favor of the M.pick-level
format_width which already accounts for the preview split ratio.
@sudo-tee

sudo-tee commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR.

With snacks picker the time is still to far right and I don't see it.

7c127e4038ea0e9d78590fd8619bbb39f4562e008d41fdda0318e884bdb716c4

If I scroll right

bd0426b0cbb5cb648da54ac133266e28153da83b76d8b8e42d2e3e3a582016d6

@phanen

phanen commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This will move me back to #402 (comment). The date is not a issue for me tbh... fzf have the ability to toggle-wrap also text is still searchable via query, but if the text will missed when it's truncated in wrong width. We still have an option to split text into multiple lines (e.g. #414)

The issue here is its real width cannot be really determined until fzf buffer is created and we get access from these variable man fzf | rg 'FZF_.*COL', that's my previous --bind start:+transform hack do, to defer text format_fn and pass environment variable ctx.

@hermandavid

Copy link
Copy Markdown
Contributor Author

I'll look into it and try to come up with some robust solution working in general.

@hermandavid hermandavid closed this Jun 9, 2026
@hermandavid hermandavid deleted the fix/picker-datetime-alignment branch June 9, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants