Skip to content

Fix/projection column width index - #55

Merged
TimelordUK merged 4 commits into
mainfrom
fix/projection-column-width-index
Aug 29, 2026
Merged

Fix/projection column width index#55
TimelordUK merged 4 commits into
mainfrom
fix/projection-column-width-index

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

No description provided.

TimelordUK and others added 4 commits August 29, 2026 11:45
…lumn widths

Column widths are computed against DataView display order and cached by visual
position, but most callers were looking them up with DataTable (source) indices.

The two index spaces coincide only for SELECT *, where visible_columns is
[0, 1, 2, ...]. Under a narrower projection - SELECT a, b, c from a wider table
- visible_columns holds arbitrary source indices, so any source index >= the
projected column count ran off the end of the width vector and silently fell
back to DEFAULT_COL_WIDTH (15). Wide values were then truncated: a timestamp
like "27/08/2026 11:59:12" rendered as "27/08/2026 11:5", and recalculating
widths could not fix it because the lookup itself was out of range.

Beyond the visible truncation this also skewed calculate_visible_column_indices,
so horizontal packing and scroll offsets were computed from wrong widths under
any projection.

- Add DataView::visual_index_of_column to translate source -> visual position,
  accounting for virtual columns occupying visual slots.
- Add ViewportManager::get_column_width_by_datatable_index for callers that
  legitimately hold source indices; pass the visual index directly where one
  was already in scope.
- Rename the width-cache parameter to visual_idx, document the distinction, and
  warn when a lookup falls out of range instead of failing silently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Entering history search (Ctrl+R) printed two unconditional debug lines straight
to stderr:

  enhanced_tui.rs      "[DEBUG] Using AppStateContainer for history search"
  app_state_container  "[DEBUG] Created N matches in history_search"

The TUI owns the terminal, so each line scrolls the display out from under
ratatui. Its renderer diffs against what it believes is on screen, so every
subsequent frame repaints only changed cells onto a display that has shifted -
leaving artifacts that persist until something forces a full repaint. Opening
the F5 debug view and escaping back happened to do exactly that, which is why
it "fixed" the display.

Convert these and the [History] diagnostics in history.rs to tracing, so they
reach the log file and the F5 debug view instead of the screen.

Guard against recurrence with #![deny(clippy::print_stdout, clippy::print_stderr)]
on the ui module tree and on app_state_container, both of which run with the
alternate screen active. CI already runs clippy, so a stray print now fails the
build rather than silently corrupting the display.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…data

Ctrl+L now forces a full repaint - the universal terminal convention, and an
escape hatch for display corruption from anything outside our control (a
resize race, a stray write from a dependency, ssh noise). It sits in the
global key map so it works in every mode, and clears ratatui's screen buffer
so the next frame repaints every cell instead of diffing against a stale one.

Ctrl+L was free: viewport lock is bound to Space and Ctrl+Space, never Ctrl+L.
The help text in help_widget.rs claiming otherwise was simply stale, and is
corrected here alongside the new binding.

The navigation debug panel searched the display-column list for current_column,
but current_column is a visual position while that list holds DataTable
indices - so any projection reported "WARNING: Current column 0 not found in
display order!" against a perfectly healthy view. It now indexes directly and
reports both spaces, which is the useful thing to see when debugging exactly
this class of confusion.

Also adds data/tc_builds_sample.csv: a wide TeamCity-shaped export whose
timestamp columns sit past the width of a typical projection over it. This is
the shape that surfaced the column-width and redraw bugs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Import ordering in history.rs and a rustfmt-preferred list break in the
projection width tests. Whitespace only; no behaviour change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@TimelordUK
TimelordUK merged commit eb29706 into main Aug 29, 2026
8 checks passed
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.

1 participant