feat: add proper indentation support for inline (nested) elements - #291
Draft
DecimalTurn wants to merge 32 commits into
Draft
feat: add proper indentation support for inline (nested) elements#291DecimalTurn wants to merge 32 commits into
DecimalTurn wants to merge 32 commits into
Conversation
… + illustrate comment ownership problem
…e arrays" and "preserves each nesting level when adding a nested array row" tests
There was a problem hiding this comment.
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(default2), 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.