Repository navigation
feat: add SelectableParagraph widget with dim effect - #41
Conversation
When content width exceeds area width and lines wrap to multiple rows, only the last wrapped row should be filled to the right edge. Changes: - Calculate wrapped line count: content_width.div_ceil(area_width) - Calculate total space needed: wrapped_lines * area_width - Fill remaining space: total_space_needed - content_width - Fix FileTree stats calculation: use individual additions_str and deletions_str instead of combined stats_str to avoid off-by-one error This ensures proper background rendering for: - FileTree: directory headers, selected files, and normal files - Editor: cursor lines Example: content_width=120, area_width=50 - Wraps to 3 lines (50 + 50 + 20 chars) - Last line needs 30 spaces fill (50 - 20 = 30) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add custom SelectableParagraph widget to replace ratatui's Paragraph with: - Character-boundary wrapping instead of word-boundary wrapping - Unicode width support for CJK characters and emojis - Configurable padding with wrap-aware behavior - Line selection with customizable styles - Distance-based dimming effect The widget preserves child element styles (z-index priority) and handles three rendering modes: no wrap, first wrap line, and continuation lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace ratatui's Paragraph with SelectableParagraph in StatusBar and Terminal panes. Move padding configuration from Block to widget for consistent wrap behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace manual background fill and wrap logic with SelectableParagraph. Add distance-based dimming effect and fix line index tracking to properly distinguish between pre-wrap line indices (for selection) and post-wrap display line indices (for scroll calculation). Changes: - Remove manual background color application from each span - Add cached_current_display_line_index for scroll calculation - Use SelectableParagraph's selection and dim features - Simplify wrap calculation to handle first line and continuation widths 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace manual cursor line background rendering and distance-based opacity with SelectableParagraph's built-in features. Remove duplicate opacity blending logic and simplify code significantly. Changes: - Remove manual padding, background fill, and wrap calculations - Remove distance_opacity from HighlightContext - Remove apply_opacity method (now in SelectableParagraph) - Use SelectableParagraph's selection highlight and dim features - Preserve cursor character rendering with proper z-index priority This reduces Editor code by ~100 lines while maintaining all functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Warning Rate limit exceeded@unhappychoice has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 20 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds a new SelectableParagraph widget and migrates editor, file tree, status bar, and terminal panes to use it; simplifies per-line styling and removes several width/opacity parameters and related helpers. Imports Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Pane as UI Pane (Editor/FileTree/Status/Terminal)
participant Widget as SelectableParagraph
participant TUI as Terminal Renderer
Pane->>Widget: Build widget (lines, selected_line, styles, padding, dim)
Widget-->>Pane: Configured widget (builder returned)
Pane->>TUI: Render Block + Widget into area
TUI->>Widget: Widget.render(area, buf)
Widget->>TUI: Draw per-line spans (wrap, selection, dim, backgrounds)
TUI-->>Pane: Buffer updated on screen
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/main.rs(1 hunks)src/panes/editor.rs(6 hunks)src/panes/file_tree.rs(9 hunks)src/panes/status_bar.rs(3 hunks)src/panes/terminal.rs(3 hunks)src/widgets/mod.rs(1 hunks)src/widgets/selectable_paragraph.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/panes/status_bar.rs (1)
src/widgets/selectable_paragraph.rs (1)
block(40-43)
src/panes/terminal.rs (1)
src/widgets/selectable_paragraph.rs (1)
block(40-43)
src/panes/editor.rs (3)
src/ui.rs (1)
new(47-68)src/animation.rs (2)
new(50-64)new(217-248)src/widgets/selectable_paragraph.rs (1)
block(40-43)
src/panes/file_tree.rs (1)
src/widgets/selectable_paragraph.rs (1)
block(40-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build (windows-latest)
- Replace Japanese comments with English - Remove unnecessary .clone() calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
SelectableParagraph handles all wrapping internally, so FileTree no longer needs to: - Calculate wrapped line counts - Track display line indices for scroll - Manage content width caching - Provide scroll offsets Also removed unused scroll feature from SelectableParagraph. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implement automatic scrolling in SelectableParagraph to keep the selected line centered in the viewport. The widget now: - Calculates the display line position of the selected original line (after wrapping) - Computes scroll offset to center the selected line - Applies the offset when extracting visible lines This handles all scrolling internally, so panes don't need to manage it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add guards to SelectableParagraph rendering to handle cases where the terminal area is smaller than the configured padding. Previously, calling buf.cell_mut().unwrap() would panic when attempting to write padding outside the available area. Changes: - Replace all .unwrap() calls with proper Option handling - Skip rendering when padding exceeds available width - Use saturating_sub() to prevent underflow in width calculations This fixes potential panics when the terminal is resized to very small dimensions or when padding is larger than the available space. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/panes/file_tree.rs(5 hunks)src/ui.rs(0 hunks)src/widgets/selectable_paragraph.rs(1 hunks)
💤 Files with no reviewable changes (1)
- src/ui.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/widgets/selectable_paragraph.rs
🧰 Additional context used
🧬 Code graph analysis (1)
src/panes/file_tree.rs (1)
src/widgets/selectable_paragraph.rs (2)
new(25-36)block(38-41)
🔇 Additional comments (5)
src/panes/file_tree.rs (5)
3-3: LGTM: Import changes align with SelectableParagraph migration.The addition of
SelectableParagraphand the updated widget imports correctly reflect the refactoring away from manual width calculations to the new widget-based approach.Also applies to: 8-8
33-55: LGTM: Cleaner API without area_width dependency.Removing the
area_widthparameter simplifies the API by delegating layout concerns toSelectableParagraph. The method now focuses solely on building content lines, while the widget handles rendering and wrapping at display time.
57-75: LGTM: SelectableParagraph configuration matches design.The rendering setup correctly:
- Separates vertical padding (Block) from horizontal padding (SelectableParagraph)
- Uses
selected_stylefor background only, preserving child span foreground colors- Applies the dimming effect with parameters matching the PR description (20 lines, 0.6 min opacity)
77-205: LGTM: Simplified line construction without manual wrapping.The refactored
build_tree_linescorrectly:
- Builds the directory tree structure and sorts entries
- Tracks
current_line_indexat the right moment (line 160, before pushing the line)- Applies foreground styling to child spans based on
is_current, lettingSelectableParagraphhandle background and dimming- Preserves status indicator colors (line 184) and stats colors (lines 191-196) independently of selection
1-206: Past review comment no longer applicable.The previous review flagged incorrect wrapped-width calculations in
calculate_wrapped_lines(mentioned lines 226-233, 291-298). This refactoring has addressed that concern by removing the manual wrapping logic entirely.SelectableParagraphnow handles all text wrapping and layout internally with awareness of its own padding (line 72), eliminating the source of the original issue.
Apply rustfmt to wrap long lines for better readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Summary
SelectableParagraphwidget to replace ratatui'sParagraphChanges
New Widget: SelectableParagraph
Refactoring Benefits
Technical Details
Wrap-aware Padding
The widget handles three rendering modes:
Child Element Priority
Child elements (spans with their own bg/fg) take precedence over parent selection styles, ensuring proper rendering of special elements like cursors.
Dim Effect
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor