Skip to content

Feature Proposal: Improved Array Literal Formatting in Typstyle #211

@Enter-tainer

Description

@Enter-tainer

generated by genai from unstructured chat log

Issue Description

Currently, the formatting of array literals in Typstyle can be improved to enhance readability and compactness. This proposal suggests several enhancements to the way array elements are formatted, particularly focusing on multi-line arrays and import sorting.

Proposed Features

  1. Multi-line Array Literals:
    • Allow array elements to be placed on the same line when possible, rather than forcing each element onto a new line. For example:
      [1, 2, 3, 4,
       5, 6, 7, 8]
      Instead of:
      [1,
       2,
       3,
       4]
    • Implement a heuristic to determine when to break lines based on element length and column width. For instance:
      • Calculate the length variance of elements.
      • Ensure no single element exceeds a certain proportion of the column width (e.g., half or one-quarter).
      • If the longest element exceeds the threshold, place each element on a new line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions