Skip to content

Add :break-on-max-column-alignment-width? option - #426

Open
sirmspencer wants to merge 2 commits into
weavejester:masterfrom
sirmspencer:ms-break-line-on-max-width
Open

Add :break-on-max-column-alignment-width? option#426
sirmspencer wants to merge 2 commits into
weavejester:masterfrom
sirmspencer:ms-break-line-on-max-width

Conversation

@sirmspencer

@sirmspencer sirmspencer commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Stacked on #425 — this PR's diff currently includes those changes too, and will narrow to just the new changes once #425 merges.

I will rebase when #425 is merged.

LLM notice

I have reviewed all of what is being submitted. The PR description was partially generated with LLM to show the current and expected behavior. Tests were generated with LLM help for completeness.

Problem

#425 added :max-column-alignment-width, which excludes keys past a given column from participating in alignment. When the excluded key is a lot longer than the aligned ones, that single space still leaves the value sitting immediately against a column it didn't participate in. This can lead to very long lines depending on the value of :max-column-alignment-width.

Current behavior

Config: {:align-map-columns? true, :max-column-alignment-width 4}

Input:

{:a 1
 :bb 2
 :ccccccc 3}

Output — :ccccccc exceeds the width, falls back to a single space, and 3 still sits flush against the aligned column set by :a/:bb:

{:a  1
 :bb 2
 :ccccccc 3}

Solution

This PR does not change the behavior of :max-column-alignment-width. Instead it adds a new flag, :break-on-max-column-alignment-width?, which only takes effect when :max-column-alignment-width is also set.

When the flag is true, a value whose key exceeds the width limit is moved onto its own line, indented under the keys, instead of falling back to a single space on the same line.

New behavior

Config: {:align-map-columns? true, :max-column-alignment-width 4, :break-on-max-column-alignment-width? true}

Input:

{:a 1
 :bb 2
 :ccccccc 3}

Output — :ccccccc still exceeds the width, but its value now moves to its own line instead of sitting against the column:

{:a  1
 :bb 2
 :ccccccc
 3}

The same behavior applies to forms with :align-form-columns?.

Changes

  • New option :break-on-max-column-alignment-width? added to default-options (false by default)
  • column-start-position now returns {:position ... :threshold ...} instead of a bare int, so pad-to-position can tell whether a given row's key exceeded the alignment-width threshold
  • pad-to-position gains a branch: when the flag is set and the key exceeds the threshold, the value is moved onto its own line (new break-to-own-line helper) instead of collapsing to a single space
  • README documents the new option and its relationship to :max-column-alignment-width
  • New test-break-on-max-column-alignment-width deftest covers form alignment, map alignment, no-op without :max-column-alignment-width, and idempotency when a value is already on its own line

Add a new :max-column-alignment-width option for column alignment.
Keys whose end column is at or within N participate in alignment;
keys that end past column N receive a single space and are not
padded.
@sirmspencer
sirmspencer force-pushed the ms-break-line-on-max-width branch from 9a93bf0 to 71ff856 Compare August 7, 2026 20:06
@sirmspencer
sirmspencer force-pushed the ms-break-line-on-max-width branch from 71ff856 to b693729 Compare August 8, 2026 21:52
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.

1 participant