Fix layout#40
Open
tiye wants to merge 4 commits into
Open
Conversation
…nline=true When use_inline=true and a SimpleExpr is block-formatted (starts with newline), subsequent sibling SimpleExprs should also be on their own lines, not appended inline. This prevented (:schema :dynamic) from being merged onto the :doc line. Adds test: sibling_simple_exprs_in_struct_keep_separate_lines_with_use_inline Bumps version to 0.2.6
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the Cirru formatter’s layout heuristics in src/writer.rs, aiming to render certain nested/special expressions more precisely in non-inline mode. It primarily adjusts how nested heads are parenthesized/indented, then updates parser and writer fixtures to match the new canonical formatting, along with a crate version bump.
Changes:
- Adjusts
generate_treeformatting rules for nested expressions, especially later clauses and boxed expressions. - Updates parser/writer fixtures for
match,indent, andcomma-indentto reflect the new layout. - Bumps the crate version from
0.2.5to0.2.7.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/writer_test.rs |
Updates the direct formatter regression test for match clause rendering. |
tests/writer_data/match.json |
Changes writer fixture input so the first match clause is a nested single-item pattern. |
tests/writer_cirru/match.cirru |
Updates expected writer output for the new match formatting. |
tests/writer_cirru/indent.cirru |
Updates expected writer output for nested boxed indentation formatting. |
tests/writer_cirru/comma-indent.cirru |
Updates expected writer output for comma/tail indentation formatting. |
tests/data/match.json |
Changes parser fixture data to match the new parenthesized single-item match clause form. |
tests/cirru/match.cirru |
Updates parser fixture source for the new match syntax expectation. |
src/writer.rs |
Implements the formatter heuristic changes and fixes a typo in an internal error string. |
Cargo.toml |
Bumps the published crate version. |
Cargo.lock |
Syncs the lockfile with the crate version bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+261
to
+263
| let mut ret = render_newline(next_level); | ||
| ret.push_str(&content); | ||
| ret |
- writer.rs: make generate_leaf pub, add doc comment explaining quoting behavior - primes.rs: add is_leaf(), is_list(), as_leaf_str(), head() as Cirru methods - parser.rs: re-export generate_leaf from crate root These changes allow downstream crates (e.g. calcit/program_diff.rs) to use the authoritative leaf formatter instead of copying the logic, and to write more idiomatic code using Cirru method dispatch.
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.
GPT 生成的上一个修改有问题, 重新改了..
特殊的表达式双层缩进, 应该更精确命中对于 let 那样的单一个情况.