Repository navigation
fix(annotations): snap floating quote overlays to device pixels to eliminate scroll jitter - #2079
Merged
Merged
Conversation
…iminate scroll jitter
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…Placing, RTL unmirrored, finite guards)
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.
Cause
Floating annotation overlays (
quote-toolbar,line-comment-toolbar, andquote-comment) render inFLOATING_CHROMEoutside the scroll container, so they carry no inheritedrigidscroll translation. During smooth scrolling (such as slow middle-click autoscroll),cx.selection_rects()andcx.window_layout()move their placement by fractional device pixels every frame:1.25×and1.75×,6sis a half-pixel (7.5,10.5), causing the quote icon to snap out of phase with the outer pill.1.1×,1.375×,1.6×,1.875×, etc.), both4sand6sare non-integer, causing both theQuotelabel and icon to jitter ±1 px independently inside the pill.line_comments::selection::toolbar(text offset6 pt, jittering even at1.25×/1.75×) andquote::editor::viewwhile riding with scroll (Placing::Riding).Fix
snap_device_px(v, origin, scale)infeatures/annotations/src/lib.rsmatching Rune's half-up rounding ((x + 0.5).floor()).quote::toolbar(features/annotations/src/quote/mod.rs) andline_comments::selection::toolbar(features/annotations/src/line_comments/selection.rs) onto whole device pixels atcx.env().scaleand applyEl::paint_contained([origin + x, origin + y])so the pill frame, icon, and text baseline share one pixel grid.quote::editor::view's band and target coordinates (features/annotations/src/quote/editor.rs) onto device pixels and applyEl::paint_containedwhilePlacing::Riding(preserving sub-pixel spring glides duringPlacing::Gliding).Before / After
Consecutive middle-click autoscroll frames (3× nearest-neighbor zoom), aligned by the outer pill's top border. Red lines mark the pill top and F0/F1 text bounds; red arrows mark ±1 px vertical jumps inside the pill.
1.375×(125% + 110% zoom)1.25×(Windows 125%)quote-toolbar@1.0× / 1.5× / 2.0×00quote-toolbar@1.25× / 1.75×214(icon ±1 px)0quote-toolbar@1.1× / 1.375× / 1.6× / 1.875×214(icon & text ±1 px)0quote-comment@1.375×(riding scroll)138(preview text ±1 px)0