Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Summary

The formatter was removing blank lines between function parameters, making long signatures with doc-comments harder to read.

Changes

  • Added .keep_linebreak(self.config.blank_lines_upper_bound) to convert_params in code_list.rs
  • Enables blank line preservation for parameters, matching existing behavior for function arguments and code blocks
  • Multiple consecutive blank lines cap at blank_lines_upper_bound (default: 2)

Before:

#let func(
  /// Description of parameter one
  hey,
  /// Description of parameter two
  ho,
) = {}

After:

#let func(

  /// Description of parameter one
  hey,

  /// Description of parameter two
  ho,

) = {}

Checklist

Before submitting, please ensure you've done the following:

  • Updated CHANGELOG.md: Added your changes with examples to the changelog
  • Updated documentation: Updated relevant docs, examples, or README
  • Added tests: Added tests for new features or bug fixes

Testing

  • Created tests/fixtures/unit/code/params-blank-lines.typ covering doc-comments, named params, rest params, and blank line capping
  • Verified existing param formatting tests still pass

Additional Notes

Aligns with rustfmt/prettier behavior of preserving limited consecutive blank lines.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Preserve empty lines between inline argument doc-comments</issue_title>
<issue_description>### What would you like?

Especially with longer function signatures and longer parameter descriptions, the signature is much better readable with empty lines between parameters like so:

// Current


/// This func does what
/// it does
#let func(
  /// Description of one 
  /// parameter. 
  /// -> int
  hey,
  /// Description of another
  /// parameter. 
  /// -> array | content
  ho,
) = {}


// Desired

/// This func does what
/// it does
#let func(

  /// Description of one 
  /// parameter. 
  hey,

  /// Description of another
  /// parameter. 
  ho,

) = {}

An option would also be to leave such newlines unchanged, leaving it up to the user but currently the formatter removes them.

Why?

This aspect of typstyle is currently the biggest reason for me not to use the formatter with large packages such as Quill or Lilaq.

For a real-world example, see for instance
https://github.com/lilaq-project/lilaq/blob/9845bdf49bdaa65b922fc4f6ed23467dce44b3ee/src/model/diagram.typ#L28-L181</issue_description>

Comments on the Issue (you are @copilot in this section)

@Enter-tainer todo for myself: see what does rustfmt do in this case @QuadnucYard rustfmt and js/ts formatter will keep at most one consecutive empty line (except the top, where no empty line is kept), by default

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add option to preserve empty lines in doc-comments Preserve blank lines between function parameters Dec 9, 2025
Copilot AI requested a review from QuadnucYard December 9, 2025 12:31
@github-actions
Copy link

📊 Benchmark Performance Report

group                               base                                   pr
-----                               ----                                   --
pretty-ai-comprehensive-showcase    1.02   911.5±17.43µs        ? ?/sec    1.00   890.6±14.04µs        ? ?/sec
pretty-cetz-manual                  1.05   794.6±20.12µs        ? ?/sec    1.00   756.2±14.62µs        ? ?/sec
pretty-codly                        1.03  1830.7±34.73µs        ? ?/sec    1.00  1783.4±22.97µs        ? ?/sec
pretty-cpe                          1.00     12.4±0.43ms        ? ?/sec    1.63     20.2±2.48ms        ? ?/sec
pretty-deep-nested-args             1.02     17.8±0.26µs        ? ?/sec    1.00     17.5±0.11µs        ? ?/sec
pretty-fletcher-diagram             1.02   528.6±10.07µs        ? ?/sec    1.00    517.8±5.79µs        ? ?/sec
pretty-fletcher-draw                1.01  1278.1±26.80µs        ? ?/sec    1.00  1263.5±42.32µs        ? ?/sec
pretty-tablex                       1.01      3.4±0.05ms        ? ?/sec    1.00      3.4±0.03ms        ? ?/sec
pretty-touying-core                 1.02      2.2±0.03ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
pretty-touying-utils                1.02  1230.9±32.37µs        ? ?/sec    1.00  1208.2±21.52µs        ? ?/sec
pretty-undergraduate-math           1.04   879.7±15.53µs        ? ?/sec    1.00   846.7±12.72µs        ? ?/sec

📏 Binary Size Comparison

Metric Base PR Change
File Size 5.9 MB 5.9 MB 📈 +32 B (+0.0%)
Text Section 1.3 MB 1.3 MB 📈 +32 B (+0.0%)
📦 Detailed Crate Size Diff (cargo-bloat)

Note: Numbers above are a result of guesswork. They are not 100% correct and never will be.

@@ -1,8 +1,8 @@
 std                       395.3 kB
 clap_builder              342.9 kB
-typstyle_core             203.9 kB
+typstyle_core             204.0 kB
 clap_complete             134.0 kB
 typst_syntax              124.5 kB
 typstyle                  54.8 kB
 similar                   33.8 kB
 walkdir                   18.8 kB

Generated by GitHub Actions on 2025-12-11 12:55:30 UTC

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.

[Feature]: Preserve empty lines between inline argument doc-comments

2 participants