Fix/projection column width index - #55
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.