Skip to content

editor: Add support for no auto-indent on enter#47751

Merged
MrSubidubi merged 8 commits intozed-industries:mainfrom
oliverbarnes:fix-auto-ident-false
Mar 4, 2026
Merged

editor: Add support for no auto-indent on enter#47751
MrSubidubi merged 8 commits intozed-industries:mainfrom
oliverbarnes:fix-auto-ident-false

Conversation

@oliverbarnes
Copy link
Copy Markdown
Contributor

@oliverbarnes oliverbarnes commented Jan 27, 2026

Closes #47550

Changes the auto_indent setting from a boolean to an enum with three modes:

  • syntax_aware (default): Adjusts indentation based on syntax context when typing (previous true behavior)
  • preserve_indent: Preserves the current line's indentation on new lines, but doesn't adjust based on syntax
  • none: No automatic indentation - new lines start at column 0 (previous false behavior)

This gives users more control over indentation behavior. Previously, setting auto_indent: false would still preserve indentation on new lines, which was unexpected.

Includes:

  • Settings migration from boolean to enum values
  • Settings UI dropdown renderer

Release Notes:

  • Changed auto_indent setting from boolean to enum with syntax_aware, preserve_indent, and none options
Screenshot 2026-01-27 at 16 32 10

When `auto_indent` is set to false, pressing Enter on an indented line
no longer copies the indentation to the new line.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 27, 2026
@MrSubidubi MrSubidubi self-assigned this Jan 27, 2026
Copy link
Copy Markdown
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

I see the use-case for this, however, this is the first complaint that we have had for this feature and I do not think this should be an on-off swich.

Can we instead refactor this setting to be an enum that holds these three variants, add/modify a settings migration for that and then go with that route?

- `full`: Adjusts indentation based on syntax context (previous `true`)
- `preserve_indent`: Preserves current line's indentation on new lines
- `none`: No automatic indentation (previous `false`)

Includes settings migration and UI dropdown renderer.
@oliverbarnes oliverbarnes changed the title editor: Don't preserve indentation when auto_indent is disabled editor: Change auto_indent from a boolean to an enum with three modes: Jan 27, 2026
@oliverbarnes
Copy link
Copy Markdown
Contributor Author

Thanks for this!

I see the use-case for this, however, this is the first complaint that we have had for this feature and I do not think this should be an on-off swich.

Can we instead refactor this setting to be an enum that holds these three variants, add/modify a settings migration for that and then go with that route?

Done!

@oliverbarnes oliverbarnes changed the title editor: Change auto_indent from a boolean to an enum with three modes: editor: Change auto_indent from a boolean to an enum with three modes Jan 28, 2026
Copy link
Copy Markdown
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor questions, otherwise looks good!

@Malix-Labs
Copy link
Copy Markdown

Malix-Labs commented Feb 7, 2026

Also see #47545 (comment) (and particularly the questions in the discussion's description)

@oliverbarnes
Copy link
Copy Markdown
Contributor Author

oliverbarnes commented Feb 10, 2026

I'm fixing the conflicts now - noticed them after re-requesting the review 😅

@MrSubidubi MrSubidubi changed the title editor: Change auto_indent from a boolean to an enum with three modes editor: Add support for no auto-indent on enter Mar 4, 2026
Copy link
Copy Markdown
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, was out sick. Looks good, thanks!

@MrSubidubi MrSubidubi enabled auto-merge (squash) March 4, 2026 20:27
@MrSubidubi MrSubidubi merged commit 9938ebe into zed-industries:main Mar 4, 2026
28 checks passed
@oliverbarnes oliverbarnes deleted the fix-auto-ident-false branch March 5, 2026 09:34
@injust
Copy link
Copy Markdown
Contributor

injust commented Mar 19, 2026

FYI, the release note is incorrect. The new default setting is syntax_aware, not full.

Also, I think breaking changes should be put at the top of the release notes, not at the very bottom lol.

@MrSubidubi
Copy link
Copy Markdown
Member

@injust Ah sorry, I forgot to update the release notes here as we decided on a different naming during the PR. Not sure how this is a breaking change though?

@injust
Copy link
Copy Markdown
Contributor

injust commented Mar 19, 2026

Not sure how this is a breaking change though?

Oh, I guess it isn't. But it's in that section at the bottom, anyway.

@MrSubidubi
Copy link
Copy Markdown
Member

Reached out to Joseph and asked about whether we can update the release notes at least partially, so thanks for pointing that out.

@oliverbarnes
Copy link
Copy Markdown
Contributor Author

Well spotted @injust, I forgot about updating it as well

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

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting auto_indent to false does not prevent Zed from maintaining the indentation level for new lines

5 participants