Skip to content

text: Support inline code style overrides - #3663

Merged
huacnlee merged 3 commits into
longbridge:mainfrom
citizenhicks:text-view-inline-code-border
Oct 24, 2026
Merged

huacnlee merged 3 commits into
longbridge:mainfrom
citizenhicks:text-view-inline-code-border

Conversation

@citizenhicks

@citizenhicks citizenhicks commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

HighlightStyle cannot express inline code font size, borders, radius, or padding. Add one inline_code_style(StyleRefinement) override for typography and box presentation, covering both font-size customization and outlined code spans. Supersedes #3639.

Unspecified properties inherit the resolved theme or explicit style. User overrides apply after surface-color adaptation, including on inverted surfaces. Existing inline_code(HighlightStyle) and with_inline_code(HighlightStyle) calls remain supported, and the public Component TextViewStyle fields are unchanged. Defaults retain the existing appearance: a 0.875 font-size ratio and no border.

Shaping, wrapping, painting, and table column measurement share font-size and inset resolution. Code and prose stay separate when their font sizes match, preventing code backgrounds and padding from extending into adjacent prose. Backgrounds and borders fade with streamed text.

English and Chinese documentation describe the supported properties. Line height remains paragraph-owned; margin, positioning, flex, explicit box dimensions, overflow, and interaction properties are not applied to inline code.

Example

use gpui_kit::{StyleRefinement, Styled as _, rems};
use gpui_kit::component::{ActiveTheme as _, text::TextView};

TextView::markdown("notes", "Run `cargo build` first.")
    .inline_code_style(
        StyleRefinement::default()
            .text_size(rems(1.))
            .px(rems(0.25))
            .border_1()
            .border_color(cx.theme().border),
    )

Public API

gpui-base

  • TextViewStyle::with_inline_code_style(self, style: StyleRefinement) -> Self — Set explicit inline code typography and box refinements.
  • TextViewStyle::inline_code_style(&self) -> &StyleRefinement — Read the explicit refinement.
  • TextView::inline_code_style(self, style: StyleRefinement) -> Self — Refine inline code over the resolved style.

gpui-component

  • text::TextView::inline_code_style(self, style: StyleRefinement) -> Self — Apply the same override through the Component facade.

Breaking Changes

None for existing consumers. Existing HighlightStyle APIs, imports, defaults, and public Component style fields remain compatible.

Validation

  • cargo test -p gpui-base -p gpui-component --features gpui-component/test-support --lib text:: --locked — 391 Base and 69 Component tests passed.
  • Tests cover equal-size code/prose separation, rem-based box measurement and wrapping at two zoom levels, style inheritance, inverted surfaces, invalid font sizes, and background/border fading.
  • cargo clippy -p gpui-base -p gpui-component --features gpui-component/test-support --all-targets --locked -- --deny warnings — passed.
  • cargo fmt --all --check, git diff --check, and whole-repository typos 1.40.0 — passed.
  • The typo dictionary now accepts the correct Portuguese word atual, resolving the unrelated CI false positive.

Validation uses headless native text/layout tests. Windows/Linux rendering and performance were not checked locally. Implementation, tests, and documentation were written with AI assistance.

citizenhicks and others added 3 commits October 24, 2026 04:05
Expose one StyleRefinement override for inline code typography and box presentation, preserving the existing HighlightStyle APIs. Keep same-size code and prose separate, and share insets across shaping, wrapping, painting, and table measurement. Covers the font-size use case from longbridge#3639.

AI-assisted implementation, regression tests, and bilingual documentation.
@huacnlee huacnlee changed the title text: Draw an optional ring around inline code text: Support inline code style refinements Oct 24, 2026
@huacnlee huacnlee changed the title text: Support inline code style refinements text: Support inline code style overrides Oct 24, 2026
@huacnlee
huacnlee enabled auto-merge (squash) October 24, 2026 05:04
@huacnlee
huacnlee merged commit 11345ec into longbridge:main Oct 24, 2026
19 checks passed
@citizenhicks
citizenhicks deleted the text-view-inline-code-border branch October 24, 2026 12:57
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