Repository navigation
fix(tui): stop narrow table panes from underflowing the column width - #587
Conversation
get_percentage_width subtracted its 3-column padding with a plain `-`, so a pane narrower than 3 columns panicked in debug builds and wrapped in release builds. Use saturating_sub, and cover get_percentage_width and truncate_text with tests. Fixes LargeModGames#540 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: LargeModGames/spotatui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangesNarrow pane width handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Narrow table panes now receive zero width for percentage-based columns when they cannot fit the padding, avoiding the previous underflow. The supplied changes identify no remaining merge-blocking risk. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 3 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@all-contributors please add @2570165831 for code |
|
I've put up a pull request to add @2570165831! 🎉 |
Adds @2570165831 as a contributor for code. This was requested by LargeModGames [in this comment](#587 (comment)) [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
# Summary Fixes #553. The SHIFT arm of `impl From<event::KeyEvent> for Key` only uppercased ASCII letters. It now uppercases any lowercase letter whose uppercase is a single char, so Shift+`ö` gives `Ö` and Shift+`é` gives `É`. `ß` (uppercase `SS`) stays `ß`. Adds the first tests for `key.rs`, with the cases from the issue: - `ö` + SHIFT gives `Ö`, `é` + SHIFT gives `É` - `ß` + SHIFT stays `ß` - `p` + SHIFT still gives `P` - `Ö` + SHIFT stays `Ö` `test_attribute_total` goes from 2291 to 2295. Rebased on top of #587, which touched the same two lines in `tools/gates.count` and the `[Unreleased]` changelog. # Testing - `cargo fmt --all -- --check`: clean - `cargo clippy --no-default-features --features telemetry,tui -- -D warnings`: clean - `cargo test --no-default-features --features telemetry,tui`: 1266 passed, 0 failed (after the rebase) - `cargo test --no-default-features --features telemetry,tui shift_with_a_lowercase`: 1 passed - With the old ASCII-only guard put back, `shift_with_a_lowercase_non_ascii_letter_gives_its_uppercase_char` fails and the other three pass. # Additional notes I tried to reproduce this on a real terminal: Ghostty 1.3.1 on macOS, with the same keyboard enhancement flags spotatui pushes (the probe reported the protocol as on). With a US (ABC) layout, in the English input mode: - Shift+P arrives as `Char('P')` with SHIFT, not `Char('p')` with SHIFT - Option-composed É arrives as `Char('É')` with no modifier - Option acts as Alt under the protocol, so Option+s arrives as `s` with ALT rather than `ß` So I couldn't hit the lowercase-plus-SHIFT case on Ghostty with a US layout. It may still show up on other terminals (#141) or on layouts with a physical ö key, which I don't have. The fix doesn't change anything for the events above. I wrote this with an AI coding assistant and reviewed the change myself. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: 2570165831 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Fixes #540.
get_percentage_widthsubtracted its 3-column padding with a plain-, so a table pane narrower than 3 columns panicked in debug builds and wrapped in release builds. It now usessaturating_sub.Also adds tests for
get_percentage_widthandtruncate_text, following the cases in the issue:(103, 0.5)gives 50truncate_text("abcdef", 4)gives"abc…"with a single…char"héllo wörld"with max 5 is checked with.chars().count()test_attribute_totalgoes from 2286 to 2291 for the five new tests.Testing
cargo fmt --all -- --check: cleancargo clippy --no-default-features --features telemetry,tui -- -D warnings: cleancargo test --no-default-features --features telemetry,tui: 1262 passed, 0 failedpercentage_width_is_zero_when_the_pane_is_no_wider_than_the_paddingfails withattempt to subtract with overflow, so the test catches the bug.Additional notes
This is the first of the small PRs mentioned in #586. I wrote it with an AI coding assistant and reviewed the change myself.
🤖 Generated with Claude Code
Summary by CodeRabbit