Skip to content

fix(auto-pairs): avoid unwanted whitespace padding in brackets and quotes - #16370

Open
rizvee wants to merge 1 commit into
helix-editor:masterfrom
rizvee:fix-autopairs-whitespace-15806
Open

rizvee wants to merge 1 commit into
helix-editor:masterfrom
rizvee:fix-autopairs-whitespace-15806

Conversation

@rizvee

@rizvee rizvee commented Oct 9, 2026

Copy link
Copy Markdown

Summary

Fixes #15806 by preventing unwanted whitespace padding inside square brackets, quotes, and backticks.

This preserves Markdown task lists such as "- [ ] item" without inserting an extra space.

Changes

  • Restrict automatic whitespace padding to parentheses and braces.
  • Preserve existing behavior for "()" and "{}".
  • Add focused regression tests covering brackets, single/double quotes, backticks, parentheses, and braces.

Scope and verification

  • One changed file: "helix-core/src/auto_pairs.rs".
  • Based directly on the latest upstream "master".
  • No unrelated LSP, transaction, or Windows build changes.
  • Regression tests added; CI results pending.

Split from #15976 following maintainer feedback to isolate independent fixes.

Closes #15806.

@woojiq

woojiq commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@dead10ck are you ok with these changes?

@dead10ck

dead10ck commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Narrowing the set of pairs for which an extra whitespace is added does make sense, but I think this calls for a more general solution.

By and large, I think there are some pairs it doesn't really make sense to add the extra whitespace, such as quotation marks, but others really depend on the particular language. Square brackets were a primary use case for adding this feature to begin with, to pad list literals; but for some languages, like markdown, this is less likely to be desirable.

I think it would make more sense to add another config option to choose which pairs will pad whitespace. Similar to editor.auto-pairs, there could be an editor.whitespace-pairs with a list of opening chars which should pad whitespace, and a corresponding language-specific config to override the global.

For example,

# config.toml
[editor]
whitespace-pairs = [
  '(',
  '{',
  '[',
]

# languages.toml
[[language]]
name = "markdown"

[language.whitespace-pairs]
whitespace-pairs = [
  '(',
  '{',
]

With this config, the default set of pairs would be all brackets, but Markdown would omit [].

For consistency, it could also accept a boolean to turn off the feature completely.

# config.toml
[editor]
whitespace-pairs = [
  '(',
  '{',
  '[',
]

# languages.toml
[[language]]
name = "markdown"

[language.whitespace-pairs]
whitespace-pairs = false

This would disable whitespace padding only for markdown.

Similarly, setting the global setting to false would disable the feature regardless of language settings.

# config.toml
[editor]
whitespace-pairs = false

# languages.toml
[[language]]
name = "markdown"

[language.whitespace-pairs]
whitespace-pairs = [
  '(',
  '{',
]

This would disable whitespace padding regardless of the markdown config.

@archseer @the-mikedavis @pascalkuthe what do you guys think?

This branch has not been deployed

No deployments
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.

Whitespace padding in auto-pairs is undesirable for markdown to-dos

3 participants