Skip to content

languages: Fix broken whitespace for C++#53709

Open
phdavis1027 wants to merge 1 commit intozed-industries:mainfrom
phdavis1027:fix/cpp-access-mod-whitespace
Open

languages: Fix broken whitespace for C++#53709
phdavis1027 wants to merge 1 commit intozed-industries:mainfrom
phdavis1027:fix/cpp-access-mod-whitespace

Conversation

@phdavis1027
Copy link
Copy Markdown

@phdavis1027 phdavis1027 commented Apr 11, 2026

Uses tree-sitter indent queries to create a pseudo-scope, since access modifiers are single-node in thetree-sitter grammar.

The @outdent capture truncates the parent { } indent range at the access specifier, keeping it at the same level as the class keyword and the pseudo-scopes from stacking.

The @outdent range selects siblings so we don't outdent the access specifiers themselves, since screenshots from the reference issue seem to show that at least one interested party does not prefer outdented access modifiers, and also it seemed like less of a departure from existing design.

Also, there are probably more tests than needed because this is my first time writing treesitter queries and I wanted to triple-guess myself. Quite open too feedback on which ones are more valuable.

Self-Review Checklist:

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

Closes #53175

Release Notes:

  • Improves handling of indentation after C++ access modifiers

Uses tree-sitter indent queries to create a pseudo-scope, since access
modifiers are single-node in thetree-sitter grammar.

The @outdent capture truncates the parent { } indent range at the
access specifier, keeping it at the same level as the class keyword
and the pseudo-scopes from stacking.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Apr 11, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, MrSubidubi and smitbarmase and removed request for a team April 11, 2026 21:02
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 11, 2026
@maxdeviant maxdeviant changed the title cpp: fix broken whitespace languages: Fix broken whitespace for C++ Apr 11, 2026
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 first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ Public causes Unintended White Space

2 participants