Skip to content

review of printing patterns#1223

Merged
Janther merged 11 commits intomainfrom
group-indent
Aug 7, 2025
Merged

review of printing patterns#1223
Janther merged 11 commits intomainfrom
group-indent

Conversation

@Janther
Copy link
Copy Markdown
Member

@Janther Janther commented Jul 29, 2025

spotted 2 patterns that further clean our printers:

  • printGroupAndIndentIfBreakPair: usually we do have a group followed by an indentIfBreak pointing to that same group. This involves creating a Symbol. All of this can be put in the same logic.

  • printIndentedGroupOrSpacedDocument: when printing (usually the body of a loop statement) we have to choose between a [' ', body] or group(indent([line, body])) this can be simplified by just having a helper with the body and a condition.

I also had a look at the printPreservingEmptyLines helper and added the logic for the comments when there are no lines. This also showed me that our printComments function was ignoring empty lines between comments.

Finally the printSeparatedItem helper has a grouped option that should always be false if the firstSeparator is a hardline

@Janther Janther requested a review from fvictorio July 29, 2025 14:58
@Janther Janther merged commit 91f326f into main Aug 7, 2025
7 checks passed
@Janther Janther deleted the group-indent branch August 7, 2025 09:02
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