From 8a775aaa2cc681042a72ae4db149c4b31a8bd4d6 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sun, 19 Jul 2020 08:23:33 -0700 Subject: [PATCH] Documentation: improve newlines.afterCurlyLambda --- docs/configuration.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 0507a15b4f..0c70b3d4a4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -886,13 +886,20 @@ else { ### `newlines.afterCurlyLambda` +This parameter controls handling of newlines after the arrow following the +parameters of a curly brace lambda or partial function, and whether a space +can be used for one-line formatting of the entire function body (if allowed +but the body doesn't fit, a break is always forced). + ```scala mdoc:defaults newlines.afterCurlyLambda ``` ```scala mdoc:scalafmt -newlines.afterCurlyLambda = never +newlines.afterCurlyLambda = squash --- +// remove all blank lines if any +// one-line formatting is allowed something.map { x => @@ -904,8 +911,11 @@ something.map { x => f(x) } ``` ```scala mdoc:scalafmt -newlines.afterCurlyLambda = always +newlines.afterCurlyLambda = never --- +// remove all blank lines if any +// one-line formatting depends on newlines.source: +// yes for fold; no for unfold; otherwise, only if there was no break something.map { x => @@ -919,6 +929,9 @@ something.map { x => f(x) } ```scala mdoc:scalafmt newlines.afterCurlyLambda = preserve --- +// if blank lines are present, keep only one +// one-line formatting depends on newlines.source: +// yes for fold; no for unfold; otherwise, only if there was no break something.map { x => @@ -930,8 +943,10 @@ something.map { x => f(x) } ``` ```scala mdoc:scalafmt -newlines.afterCurlyLambda = squash +newlines.afterCurlyLambda = always --- +// ensure a single blank line +// one-line formatting is not allowed something.map { x =>