Repository navigation
editor: Clip the text to its own side of the gutter - #3426
Merged
Merged
Conversation
A code editor without line numbers still keeps a gutter for the fold icons and the margin, so the text is clipped to its side of it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
huacnlee
approved these changes
Oct 11, 2026
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.
Description
The editor's gutter is painted over the horizontally scrolling text, and its background is what hides the text underneath. That background is not always opaque: a disabled editor paints the editor background at half opacity, and a theme may give
editor.backgroundoreditor.gutter.backgroundan alpha. The text then shows through the gutter, under the line numbers.With the gutter on the right (#3417) every line longer than the pane runs under the gutter, so in a side-by-side diff it shows on most rows. With a gutter on the left it shows once the text is scrolled horizontally.
This clips what belongs to the text area to its own side of the gutter — glyph backgrounds, indent guides, range decorations, selections and search matches, the hover highlight, document colors, the text and its ghost lines, inline elements, the carets and the inline completion suffix — instead of relying on the gutter's background to cover it. Only the edge facing the gutter moves; the other edges stay those of the current content mask. Line decoration backgrounds and the active line keep spanning the gutter, and the gutter keeps its background. Nothing changes for an editor without line numbers.
Screenshot
A side-by-side diff in a dark theme, the left pane with
.gutter_side(Side::Right):How to Test
cargo test -p gpui-base --lib the_text_is_clipped_to_its_side_of_the_gutter: a decorated text scrolled under the gutter, for a gutter on the left and on the right with either scrollbar placement; it reads what was painted (painted_quads,painted_underlines) and fails without the clip..gutter_side(Side::Right)whose editor background is not opaque (for example a disabled one), type a line longer than the pane: the line numbers sit on the gutter's background, not over the text.Checklist
cargo runfor story tests related to the changes.