Skip to content

Commit

Permalink
all: clarify that the "keep padding" formatting option is deprecated
Browse files Browse the repository at this point in the history
Back in 2022 in #658 I already decided this option will be removed in v4
yet the documentation did not make this clear, so users could be
misled into thinking it's a good idea to use it today.

For #658.
  • Loading branch information
mvdan committed Oct 19, 2024
1 parent 25c0048 commit 26182ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/shfmt/shfmt.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ predictable. Some aspects of the format can be configured via printer flags.
*-kp*, *--keep-padding*
Keep column alignment paddings.

This flag is *DEPRECATED* and will be removed in the next major version.
For more information, see: https://github.com/mvdan/sh/issues/658

*-fn*, *--func-next-line*
Function opening braces are placed on a separate line.

Expand Down
5 changes: 5 additions & 0 deletions syntax/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func SpaceRedirects(enabled bool) PrinterOption {
// Note that this feature is best-effort and will only keep the
// alignment stable, so it may need some human help the first time it is
// run.
//
// Deprecated: this formatting option is flawed and buggy, and often does
// not result in what the user wants when the code gets complex enough.
// The next major version, v4, will remove this feature entirely.
// See: https://github.com/mvdan/sh/issues/658
func KeepPadding(enabled bool) PrinterOption {
return func(p *Printer) {
if enabled && !p.keepPadding {
Expand Down

0 comments on commit 26182ab

Please sign in to comment.