Skip to content

editor: Add support for customizable soft wrap indentation - #62099

Closed
arusahni wants to merge 6 commits into
zed-industries:mainfrom
arusahni:feat/soft-wrap-indent
Closed

arusahni wants to merge 6 commits into
zed-industries:mainfrom
arusahni:feat/soft-wrap-indent

Conversation

@arusahni

@arusahni arusahni commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Objective

  • Soft wrapped lines currently inherit the indentation of their first line. This can be challenging for those coming from different editors, or with different expectations.
  • Allow users to customize the soft wrap behavior to wrap with extra indent, or no indent at all.
  • Fixes Extra indent for soft-wrapped lines #18687

Solution

  • Introduce 3 soft-wrap indent configuration values (in addition to the default of same): none, extra_one, and extra_two (where they are multiples of the indent column width).
  • Plumb indent configuration through to the various gpui and editor components that are concerned with wrapping.
  • Update code action icon placement to accommodate none-level wrap indentation (preceded by a refactor of the function used to calculate its display row).
  • Fixed an existing bug in WrapSnapshot::soft_wrap_indent where querying a 0-indent wrap returned None instead of Some(0)

Testing

  • Added tests to wrap_map.rs for all indentation levels.
  • Updated the random wrap tests to include indent setting combinations.
  • Added tests for code action icon placement.
  • Validated locally by toggling between the various settings and observing how the wrap behaved.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Showcase

Screenshots below! Changes are grouped by commit to ease review.

Click to view showcase

same indent (current Zed behavior)
Screenshot from 2026-08-02 22-45-54

none indent
Screenshot from 2026-08-02 22-45-39

extra_one indent
Screenshot from 2026-08-02 22-46-06

extra_two indent
Screenshot from 2026-08-02 22-46-19

the setting
Screenshot from 2026-08-02 22-42-19


Release Notes:

  • Added a soft_wrap_indent setting ("none", "same", "extra_one", "extra_two") to configure indentation for soft-wrapped continuation lines.
  • Fixed soft-wrap continuation line indentation calculation for unindented lines starting at column 0.

This allows callers to specify how indentation for soft-wrapped
lines should function. For now this uses the existing default of
same-level indentation.
Also add soft_wrap_indent tests.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 3, 2026
@maxdeviant maxdeviant changed the title editor: add support for customizable soft wrap indentation editor: Add support for customizable soft wrap indentation Aug 3, 2026
@arusahni
arusahni force-pushed the feat/soft-wrap-indent branch from 2ecc39d to 5490cd0 Compare August 3, 2026 11:17
This is a 1:1 refactor of the existing calculation. A subsequent commit
will introduce the change that necessitated this refactor.
Because soft-wrapped display rows now can start on a *lower* indent
column than the first display row, we cannot rely on the first row's
indent, and now need to check to see if there's enough space to display
the code action. If not, use the first display row for the buffer for
the code action placement calculation.
@arusahni
arusahni force-pushed the feat/soft-wrap-indent branch from 5490cd0 to 9ffe45f Compare August 3, 2026 11:17
@smitbarmase smitbarmase added the area:editor Feedback for code editing, formatting, editor iterations, etc label Aug 3, 2026
@SomeoneToIgnore SomeoneToIgnore self-assigned this Aug 18, 2026
@SomeoneToIgnore

Copy link
Copy Markdown
Contributor

Thank you for the PR: seems that all checks fail due to the code not being able to compile: will close it for now as we'd want something a bit more finished and polished on the topic.

@arusahni

Copy link
Copy Markdown
Contributor Author

@SomeoneToIgnore ugh, that's an embarrassing oversight on my part - I missed some tests when changing a function signature. I'm sorry for wasting some of your cycles.

I have pushed this out (fixed) as a different PR in #63468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editor Feedback for code editing, formatting, editor iterations, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra indent for soft-wrapped lines

3 participants