Skip to content

✨ feat(mq-lang): add dedent and common_indent builtins - #2332

Merged
harehare merged 2 commits into
mainfrom
feat/dedent-common-indent
Sep 12, 2026
Merged

✨ feat(mq-lang): add dedent and common_indent builtins#2332
harehare merged 2 commits into
mainfrom
feat/dedent-common-indent

Conversation

@harehare

Copy link
Copy Markdown
Owner

Summary

Adds common_indent(s) to compute the longest shared leading whitespace across a string's non-blank lines, and dedent(s) to strip it, normalizing blank lines to empty. Makes generating templates, quoted text, and code blocks easier to write.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

Adds common_indent(s) to compute the longest shared leading
whitespace across a string's non-blank lines, and dedent(s) to
strip it, normalizing blank lines to empty. Makes generating
templates, quoted text, and code blocks easier to write.
@harehare
harehare force-pushed the feat/dedent-common-indent branch from 5ad86c5 to 2128c5a Compare September 12, 2026 08:55
@codspeed-hq

codspeed-hq Bot commented Sep 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 51 untouched benchmarks


Comparing feat/dedent-common-indent (69cdc14) with main (bed9aa0)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (a567ea4) during the generation of this report, so bed9aa0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Type narrowing ran before user-defined function call return types were
propagated, so `let y = f(x) | if (y != None): ...` couldn't narrow away
None on f's result, causing spurious NullablePropagation errors (e.g. in
builtin.mq's dedent). Also guards dedent's prefix lookup with `!= None`.
@harehare
harehare merged commit 625c8f9 into main Sep 12, 2026
12 checks passed
@harehare
harehare deleted the feat/dedent-common-indent branch September 12, 2026 10:35
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.

1 participant