Repository navigation
input: Draw a placeholder for a folded line - #3791
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ckground Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Changed direction before review, in 4709444: the placeholder now follows VS Code instead of IntelliJ, and the description is rewritten to match.
|
huacnlee
left a comment
There was a problem hiding this comment.
This makes folded code visible beyond the gutter chevron by allowing an application-owned trailing placeholder and folded-row background. That is a reasonable editor capability; the names describe their scope, and keeping both opt-in preserves the existing appearance. The remaining concern is Rust API compatibility.
- P2 — Preserve existing
InputEditorStyleconsumers (crates/base/src/input/editor/highlighting.rs:123–127). The two added public fields break existing exhaustive struct literals. I verified a consumer listing the previous twelve fields: it compiles against current main1ded8be6, but fails with E0063 against47094447becauseeditor_fold_backgroundandfold_placeholder_rendererare missing. The description correctly acknowledges this, but the repository currently requires existing consumers to remain compatible. Please use state setters backed by private storage, as suggested in the description, or explicitly agree a breaking-release migration before landing. Retrofitting#[non_exhaustive]alone also breaks those existing literals and does not solve this compatibility requirement. Please also list the new items under the required## Public APIsection.
Validation on Linux, head 470944475533cce543b8838ec7baf3f58414eb83:
cargo fmt --check: passed before adding local review fixtures.cargo test -p gpui-base --features test-support --lib input::: 416 passed, including the new placeholder click regression.cargo clippy -p gpui-base --lib --features test-support -- --deny warningsandcargo clippy -p gpui-component --lib -- --deny warnings: passed.- Built a local Base editor fixture and ran actual X11 windows under Xvfb on current main and the PR. The folded row gains its background and trailing dots only on the PR; clicking the dots unfolds it. Saved a side-by-side comparison locally for the owner. No contributor-branch changes were pushed.
- The broader
--all-targetsClippy invocations could not complete: withouttest-support, existing Base tests reference a gatedcrate::test_support; enabling it across Base/Component instead exposesObserved<E>.vertical_scrollbarinpopup_menu.rs. These are outside this diff; the narrower production-library checks above passed.
Not verified here: light theme, HiDPI, actual wrapped-header geometry, horizontal scrolling, inline-completion ghost rows, centered/right-aligned text, keyboard/accessibility activation of the new placeholder, macOS or Windows. The documented overflow/scroll-range limitation remains present and was not treated as a newly discovered defect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Moved both to setters on the state in ca8806d, so the PR no longer touches state.set_fold_placeholder_renderer(Some(renderer), cx);
state.set_fold_background(Some(color), cx);They are backed by private fields on Ran |
There was a problem hiding this comment.
This adds an opt-in trailing placeholder and row background so folded code is recognizable without relying only on the gutter. The application still owns the placeholder presentation, and the new state setters describe their scope appropriately.
Follow-up review of ca8806da3456db04b64364abdf4301425874d18e: the previous compatibility finding is resolved. The storage is private on InputBaseState; InputEditorStyle is unchanged from the base branch, and the description now lists the renderer alias and both setters under Public API. I rebuilt the previous exhaustive twelve-field InputEditorStyle consumer successfully. No new blocking finding in this delta.
Validation on Linux:
cargo test -p gpui-base --features test-support --lib input::: 416 passed, including the placeholder click regression.- Repository
cargo fmt --all --check: passed after removing the local review fixture. cargo clippy -p gpui-base --lib --features test-support -- --deny warnings: passed.- Rebuilt and ran the Base editor fixture in an actual X11 window under Xvfb using the new setters. The folded background and trailing dots appear, and clicking the dots unfolds the line. Compared against the main fixture screenshot retained from the preceding review; the rendering implementation itself is unchanged by this follow-up.
The earlier documented coverage limits remain: this fixture covers dark theme at 1x and the simple click flow, not light theme, HiDPI, genuinely wrapped headers, horizontal-scroll extent, ghost completion rows, centered/right alignment, keyboard/accessibility activation, or native macOS/Windows interaction. The documented placeholder overflow/scroll-range limit also remains. Current CI is still pending; this comment is not a merge approval. No contributor branch changes were pushed.
Description
A folded line in the editor looks like any other line: only the gutter chevron tells that lines are hidden under it. VS Code marks a folded line with a
⋯right after its text and a background across the line (editor.foldBackground).This lets an application do the same, through two setters on the editor state:
⋯0.2emon each side.InputEditorStyleis untouched.The renderer gets the row, so the application decides what to show. We draw a muted
⋯with VS Code's spacing.Not handled. The placeholder is not counted in the line's width: with soft wrap, a last row that already fills the width pushes it past the edge, where it is clipped, and without soft wrap it is not part of the horizontal scroll range.
Public API
gpui-base:gpui_base::input::FoldPlaceholderRenderer = Rc<dyn Fn(usize) -> AnyElement>— draws the placeholder of a folded line, given its buffer row.InputBaseState::set_fold_placeholder_renderer(&mut self, renderer: Option<FoldPlaceholderRenderer>, cx: &mut Context<Self>)— draws that placeholder right after the text of each folded line; clicking it unfolds the line.InputBaseState::set_fold_background(&mut self, color: Option<Hsla>, cx: &mut Context<Self>)— fills each folded line across the editor, as VS Code'seditor.foldBackground.How to Test
input::element::tests::a_folded_line_shows_its_placeholder_right_after_the_text_and_unfolds_on_clickfoldstop {over two lines and checks that:top {, unfolds it. This part fails with the unfold handler removed.Checks run:
cargo clippy --workspace --exclude gpui-shell --exclude webview -- --deny warnings, as CI runs it: clean.cargo test -p gpui-base --features test-support --lib: 1578 passed.cargo test -p gpui-component --lib: 758 passed.cargo check -p gpui-component --no-default-features: clean.cargo fmt --check: clean.Verified by hand on macOS in an editor with folding and line numbers, with C in Menlo and Markdown in Pretendard: the
⋯follows the text, the folded row is filled, and clicking the⋯unfolds the line.Not run: the story gallery, Windows and Linux, and centered or right-aligned text.
The change and test were written with Claude Code.
Checklist
cargo runfor story tests related to the changes.🤖 Generated with Claude Code