Skip to content

Fix layout#40

Open
tiye wants to merge 4 commits into
mainfrom
fix-layout
Open

Fix layout#40
tiye wants to merge 4 commits into
mainfrom
fix-layout

Conversation

@tiye
Copy link
Copy Markdown
Member

@tiye tiye commented May 3, 2026

GPT 生成的上一个修改有问题, 重新改了..

特殊的表达式双层缩进, 应该更精确命中对于 let 那样的单一个情况.

tiye added 2 commits May 3, 2026 11:58
…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
@tiye tiye requested review from a team and Copilot May 3, 2026 04:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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_tree formatting rules for nested expressions, especially later clauses and boxed expressions.
  • Updates parser/writer fixtures for match, indent, and comma-indent to reflect the new layout.
  • Bumps the crate version from 0.2.5 to 0.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 thread src/writer.rs
Comment on lines +261 to +263
let mut ret = render_newline(next_level);
ret.push_str(&content);
ret
tiye added 2 commits May 13, 2026 01:28
- 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.
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