Skip to content

feat: add proper indentation support for inline (nested) elements - #291

Draft
DecimalTurn wants to merge 32 commits into
latestfrom
dev-array-multi
Draft

feat: add proper indentation support for inline (nested) elements#291
DecimalTurn wants to merge 32 commits into
latestfrom
dev-array-multi

Conversation

@DecimalTurn

Copy link
Copy Markdown
Owner

No description provided.

…e arrays" and "preserves each nesting level when adding a nested array row" tests
Copilot AI lite review requested due to automatic review settings August 21, 2026 06:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces style-aware indentation support when inserting into multiline inline arrays/tables (including nested inline elements) by adding an indentWidth formatting concept, auto-detecting it from existing TOML, and propagating it into writer insertion logic.

Changes:

  • Add TomlFormat.indentWidth (default 2), validation, documentation, and auto-detection (including tab handling).
  • Teach writer.insertInline / inline positioning to use an explicit indentation width when inferring first-row columns in multiline inline containers.
  • Add a helper (prepareInsertedNestedInlineContainer) plus extensive new/updated tests covering indentation and nesting scenarios.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/writer.ts Stores per-root indent width and uses it when inserting into inline containers to align new multiline rows correctly.
src/toml-format.ts Adds DEFAULT_INDENT_WIDTH, indentWidth option, auto-detection logic, validation, and propagation through TomlFormat.
src/patch.ts Propagates detected/explicit indent width into writer operations and prepares nested inline containers before insertions.
src/parse-js.ts Propagates indent width into parseJS-generated CST roots and prepares nested inline insertions for arrays.
src/inline-layout.ts New helper to align nested inline containers based on an existing template container’s multiline layout.
src/tests/toml-format.test.ts Adds assertions for indent width defaults and detection (spaces and tabs).
src/tests/patch.test.ts Enables an existing “multiline empty array” test and adds coverage for indent-width-sensitive behavior.
src/tests/patch.indentation.test.ts New focused test suite for indentation preservation across many patch scenarios (root, tabs, nesting, edge cases).
src/tests/patch.fuzz.test.ts Updates fuzz expectations to match the new indentation/layout behavior.
src/tests/patch.dotted-key-spacing.test.ts Adds (currently failing) tests documenting desired dotted-key spacing preservation behavior.
README.md Documents useTabsForIndentation and the new indentWidth option with examples.
docs/PLAN-Indentation.md Adds a detailed design/plan document for style-aware indentation behavior and future work.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/toml-format.ts Outdated
Comment thread src/toml-format.ts Outdated
Comment thread src/toml-format.ts Outdated
Comment thread src/__tests__/patch.indentation.test.ts Outdated
Comment thread src/__tests__/patch.indentation.test.ts Outdated
Comment thread src/__tests__/patch.dotted-key-spacing.test.ts Outdated
Comment thread src/__tests__/patch.dotted-key-spacing.test.ts Outdated
Comment thread src/__tests__/patch.dotted-key-spacing.test.ts Outdated
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.

2 participants