fix: add horizontal scroll to rendered markdown code blocks#10008
fix: add horizontal scroll to rendered markdown code blocks#10008yingxuel wants to merge 1 commit intowarpdotdev:masterfrom
Conversation
…ev#9089) Code blocks in the rendered-markdown notebook view were silently clipped at the pane edge with no way to reach overflowing content. Raw mode already had a horizontal scrollbar; this brings rendered mode to parity. Root cause: `RenderableRunnableCommand` drew paragraphs with no clip layer and no scroll state, so text wider than the container was painted off-screen and swallowed by the outer editor clip. Changes: - `paint.rs`: add `draw_paragraph_scrolled` which temporarily increments `RenderContext::nested_horizontal_scroll` so that `content_to_screen` shifts text, selection, cursors, and decorations together. - `runnable_command.rs`: track `scroll_left`, `natural_width`, `viewport_bounds`, `scrollbar`, `scrollbar_hovered`, and `scrollbar_drag`; paint a `BoundedByActiveLayerAnd` clip layer around code content; render a horizontal scrollbar thumb (same colours as the table scrollbar); handle shift-scroll / horizontal trackpad gesture and scrollbar drag in `dispatch_event` — mirroring `RenderableTable`. - 10 unit tests covering max-scroll arithmetic, scroll data, delta gating (vertical vs shift/horizontal vs precise), line-multiplier scaling, and scroll-left clamping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds nested horizontal scrolling and scrollbar handling for rendered markdown runnable code blocks.
Concerns
- The new scroll offset only affects painting/event dispatch inside
RenderableRunnableCommand; model-level hit testing for code blocks still uses unscrolled coordinates, so clicks, selection, cursor placement, and link hover can target the wrong text after horizontal scrolling.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| footer: Box<dyn Element>, | ||
| border: Option<Border>, | ||
| /// Current horizontal scroll offset in pixels. | ||
| scroll_left: f32, |
There was a problem hiding this comment.
scroll_left only on the renderable means RenderState hit testing remains unaware of the horizontal offset; after scrolling, clicks/selection/link hover in the code block will resolve against unscrolled coordinates. Move the scroll state into the render model or otherwise feed it into code-block coordinate-to-location logic.
Description
Rendered markdown code blocks in the notebook file view were silently clipped at the pane edge with no affordance to reach overflowing content. Switching to Raw mode showed a horizontal scrollbar; Rendered mode had none.
Root cause:
RenderableRunnableCommanddrew paragraphs directly to the scene with no clip layer and no scroll state. Monospace code lines wider than the container extended past the right edge and were swallowed by the outer editor clip. (RenderableTablealready has a full horizontal-scroll implementation; this brings code blocks to parity.)Changes:
crates/editor/src/render/element/paint.rs— addsdraw_paragraph_scrolled, which temporarily incrementsRenderContext::nested_horizontal_scrollso thatcontent_to_screenshifts text, selection highlights, cursors, and syntax-highlight decorations together under the scroll offset.crates/editor/src/render/element/runnable_command.rs— tracksscroll_left,natural_width,viewport_bounds,scrollbar,scrollbar_hovered, andscrollbar_drag; wraps code content in aBoundedByActiveLayerAndclip layer; renders a horizontal scrollbar thumb (reusing the table scrollbar colours from the active theme); handles shift-scroll / horizontal trackpad and scrollbar drag indispatch_event, mirroringRenderableTable.ScrollDataconstruction, delta gating (plain vertical →None, shift-scroll and horizontal trackpad →Some), line-multiplier scaling for imprecise scroll, andscroll_leftclamping at both edges.Linked Issue
Fixes #9089
ready-to-specorready-to-implement.Screenshots / Videos
recording_9089.mov
Testing
runnable_command.rs(seecode_block_scroll_testsmodule); all pass withcargo nextest run -p warp_editor.warp_editorsuite: 422/422 pass, zero regressions.masterbefore this branch was created (verified by checking outmasterwithout these changes). These failures are pre-existing and unrelated to this PR.Agent Mode
CHANGELOG-BUG-FIX: Rendered markdown code blocks now scroll horizontally when content overflows the pane width, matching Raw mode behaviour.