fix: add horizontal scroll to rendered markdown code blocks#10008
fix: add horizontal scroll to rendered markdown code blocks#10008yingxuel wants to merge 3 commits 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
…esting Moves `scroll_left` from the `RenderableRunnableCommand` struct into `BlockItem::RunnableCodeBlock` (as `Cell<Pixels>`, matching the table pattern) so that hit-testing code paths — `character_bounds` and `coordinate_to_location` — can account for horizontal scroll when resolving clicks, selections, and link hovers inside scrolled code blocks. Also strengthens types from `f32` to `Pixels` throughout, and moves scroll clamping from `paint()` to `layout()` so it runs before the scene is built. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review 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 adds per-code-block horizontal scroll state, clipping, scrollbar painting, and adjusted hit-testing for rendered markdown code fences.
Concerns
- The new code-block clip layer is not marked click-through, unlike the table implementation it mirrors. That can make the layer cover the rich-text content for pointer hit-testing and break selecting/clicking inside code blocks.
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
Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review 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 horizontal overflow clipping, scroll state, scrollbar rendering, event handling, and hit-testing updates for rendered markdown code blocks.
Concerns
- Scrollbar drag interaction state is stored on the renderable block, which is rebuilt during layout after notifications, so the thumb drag can be lost immediately after mouse down.
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
| if thumb_hit { | ||
| let scroll_data = | ||
| code_block_scroll_data(natural_width, container_width, scroll_left.get()); | ||
| self.scrollbar_drag = Some(CodeBlockScrollDrag { |
There was a problem hiding this comment.
ctx.notify() can trigger a layout pass, and RichTextElement::layout rebuilds RenderableBlocks, so storing the drag state on RenderableRunnableCommand drops it before the next LeftMouseDragged; persist this interaction state in the render model like LaidOutTable does.
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.