Repository navigation
Agent: give code blocks a horizontal scrollbar - #1666
Draft
maple-engineering[bot] wants to merge 1 commit into
Draft
maple-engineering[bot] wants to merge 1 commit into
maple-engineering[bot] wants to merge 1 commit into
Conversation
A code block already kept its longest line on one line, but the only way to move it sideways was a trackpad or a shift-wheel over the body: no bar was drawn, so with a mouse the clipped end was unreachable. The block is now an element that keeps a ScrollHandle in element state, and draws the same overlay horizontal bar markdown tables use along its bottom edge, inside the body's existing bottom padding. Co-authored-by: Maple Engineering <ed24cd5651d75896f9c44c4caf0efe89abd3b86a7531feffdf6b87e3cc0bc37c@buzz-01.tail87ed4d.ts.net>
This branch has not been deployed
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.
What
Fixes #1664.
A code block already kept its longest line unwrapped and clipped it at the block edge, but it never drew a horizontal scrollbar. The scroll region only answered a trackpad or shift-wheel, so with an ordinary mouse the clipped end of a long URL or command was unreachable.
The block now keeps a
ScrollHandlein element state and draws the same overlay horizontal bar markdown tables already use (scrollbar::horizontal_scrollbar), along the block's bottom edge inside the body's existing bottom padding. The bar hides while the content fits, appears when the pointer is over its strip, while scrolling, or during a drag, and drags/pages the code sideways like the table bar.Diff
apps/maple-agent/app/src/ui/rich_text.rs:code_blockreturns aCodeBlockElementinstead of aDiv. Itsrequest_layouttakes the persistent handle fromwindow.with_element_state(same pattern asmarkdown/table.rs) and builds the existing tree with.track_scroll(&scroll)plus the overlay bar. Selection ordinals, copy button, language label and unwrapped line measurement are unchanged.Validation
just ci-lint— pass (fmt, clippy-D warningsfor every feature set, dependency graph checks).just ci-testequivalent (RUSTFLAGS="-D warnings" cargo test --workspace --locked) — 3036 passed, 0 failed.I did not add a UI test: the bar component's geometry and drag behavior are already covered in
ui/scrollbar.rs, and this change only wires the tested component into the block. I have not run the GUI itself; a quick look at a long code block in the desktop app would confirm the bar's placement.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.