Skip to content

editor: Clip the text to its own side of the gutter - #3426

Merged
huacnlee merged 2 commits into
longbridge:nextfrom
glani:editor-clip-text
Oct 11, 2026
Merged

huacnlee merged 2 commits into
longbridge:nextfrom
glani:editor-clip-text

Conversation

@glani

@glani glani commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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.background or editor.gutter.background an 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):

Before After
before: the text shows through the gutter after: the text ends at the gutter

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.
  • In an editor with .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

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

glani and others added 2 commits October 9, 2026 21:49
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
huacnlee merged commit 24ded30 into longbridge:next Oct 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants