Skip to content

fix: stop emitting trailing whitespace before multi-tactic tacticSeq arguments - #14693

Open
jcreinhold wants to merge 1 commit into
leanprover:masterfrom
jcreinhold:fix/pp-trailing-whitespace-sepByIndent
Open

fix: stop emitting trailing whitespace before multi-tactic tacticSeq arguments#14693
jcreinhold wants to merge 1 commit into
leanprover:masterfrom
jcreinhold:fix/pp-trailing-whitespace-sepByIndent

Conversation

@jcreinhold

Copy link
Copy Markdown
Contributor

This PR fixes the pretty printer leaving a trailing space on the row above a multi-tactic indented tacticSeq argument, as in iterate 1␣, and the whitespace-only blank line emitted instead at narrow widths.

A multi-tactic tacticSeq starts with a forced line break (Format.align true, emitted by sepByIndent.formatter). When a breakable space (ppSpace) precedes it, the enclosing group could flatten that space even though the forced break fired immediately after it, stranding the space at the end of the row. The renderer now refuses to flatten a line whose next output is a forced align that will break, and drops the align when the line already broke to the same column.

Closes #14692

@jcreinhold
jcreinhold requested a review from kim-em as a code owner August 5, 2026 19:06
@jcreinhold
jcreinhold force-pushed the fix/pp-trailing-whitespace-sepByIndent branch from d829102 to 4c8cc87 Compare August 5, 2026 19:08
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 5, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 4c29de6f2cb93ffdabd2838c1eed6f55061bb605 --onto f2bcf2e8660ab2d16cf3cb50c8e127de0439a337. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-05 19:36:51)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 4c29de6f2cb93ffdabd2838c1eed6f55061bb605 --onto 23393b959b33e3a8d15796b2397f8a04c315b9f4. You can force reference manual CI using the force-manual-ci label. (2026-08-05 19:36:53)

@jcreinhold
jcreinhold force-pushed the fix/pp-trailing-whitespace-sepByIndent branch from 4c8cc87 to 1ec0b5f Compare August 5, 2026 19:46
…` arguments

This PR fixes the pretty printer emitting a trailing space before a
multi-tactic indented `tacticSeq` argument, as in `iterate 1␣` followed by
an indented sequence, and the whitespace-only blank line produced when the
separator broke at narrow widths.

A multi-tactic `tacticSeq` begins with a forced `align` (a hard line break)
emitted by `sepByIndent.formatter`. When a flattenable separator such as
`ppSpace` precedes the sequence, the enclosing group could flatten the
separator into a space even though the `align` then broke immediately,
stranding the space at the end of the row. The renderer now tracks whether
the current row is still fresh (no output since the last line break): a
`line` immediately followed by a forced `align` that will break is broken
instead of flattened, and an `align` already at its indentation level on a
fresh row is a no-op rather than emitting a second, whitespace-only line.
@jcreinhold
jcreinhold force-pushed the fix/pp-trailing-whitespace-sepByIndent branch from 1ec0b5f to a48d2b5 Compare August 5, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatter emits trailing whitespace before multi-tactic tacticSeq arguments

2 participants