Skip to content

feat: leading-ampersand option to drop the optional & on continuation lines - #17

Merged
sbryngelson merged 2 commits into
masterfrom
leading-ampersand-option
Oct 17, 2026
Merged

sbryngelson merged 2 commits into
masterfrom
leading-ampersand-option

Conversation

@sbryngelson

Copy link
Copy Markdown
Owner

Closes #15.

Adds an opt-in leading-ampersand option (default true, so existing output is unchanged). With leading-ampersand = false the optional leading & is dropped from continuation lines and the alignment is kept:

call s_foo(x, &
           y, z)

It is a final pass, so every earlier pass still sees the canonical & form. The & is kept where Fortran requires it (a continued character literal) and where dropping it would expose a #, !, $: or @: line to the parser.

Checked on 335 real Fortran files: the only change between true and false is the removed & (14,807 lines), line counts are identical, and gfortran reports the same diagnostics for both outputs. Tests are in tests/config_integration.rs plus a unit-test module in src/formatter.rs (the string-literal guard is only reachable there, because ffmt rejoins split strings first). Documented in docs/configuration.md.

cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass locally.

Note: this touches src/formatter.rs near #16 and will conflict textually with it (adjacent helper functions). It is based on master, not stacked; I will rebase it after #16 merges.

@sbryngelson
sbryngelson force-pushed the leading-ampersand-option branch from 9bb9e84 to 6d6b66f Compare October 17, 2026 19:55
@sbryngelson
sbryngelson merged commit 1b84500 into master Oct 17, 2026
9 checks passed
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.

Optional ampersand in the beginning of continuation lines

1 participant