Keep lambda parameters on one line and parenthesize the body if it expands #21385
ntBre
commented
on 2025-11-11
ntBre
force pushed
from
6e9b2bd5
to
958f0499
350 days ago
ntBre
force pushed
from
93fffd1b
to
b65c4077
350 days ago
ntBre
force pushed
from
b65c4077
to
68e09d51
350 days ago
ntBre
force pushed
from
68e09d51
to
19326a7b
350 days ago
ntBre
commented
on 2025-11-12
ntBre
changed the title [WIP] Indent lambda parameters if parameters wrap [WIP] Keep lambda parameters on one line and parenthesize the body if it expands 349 days ago
ntBre
changed the title [WIP] Keep lambda parameters on one line and parenthesize the body if it expands Keep lambda parameters on one line and parenthesize the body if it expands 348 days ago
ntBre
marked this pull request as ready for review 348 days ago
ntBre
marked this pull request as draft 343 days ago
ntBre
force pushed
from
32d7d52d
to
c405b416
343 days ago
ntBre
force pushed
from
c405b416
to
1bfcf511
342 days ago
ntBre
force pushed
from
7dac1279
to
b441ac64
341 days ago
ntBre
changed the title Keep lambda parameters on one line and parenthesize the body if it expands Parenthesize long lambda bodies 341 days ago
ntBre
force pushed
from
b441ac64
to
c2db35b1
341 days ago
ntBre
changed the title Parenthesize long lambda bodies Keep lambda parameters on one line and parenthesize the body if it expands 341 days ago
ntBre
force pushed
from
c2db35b1
to
56c533c9
341 days ago
ntBre
commented
on 2025-11-21
ntBre
force pushed
from
f04a18d8
to
6e7a2dce
331 days ago
ntBre
force pushed
from
ad77cfae
to
20982524
330 days ago
baseline test cases
1e70c991
keep lambda parameters on a single line
8cc88442
wip: parenthesize long lambda bodies
1b586430
add a poorly formatted case from the ecosystem report
74093bdb
add an unstable test case from ecosystem report
a5e13cf1
rough draft of ExprLambdaLayout::Assignment
62c968c8
add another bad case from the ecosystem check
d68a03a5
fix binary expression in lambda in return
07bcf41a
add another bad test case from the ecosystem report
6b476640
propagate lambda layout for annotated assignments
f634bb52
another bad test for long bodies with their own parens
ad314770
possibly bad test for triple-quoted f-strings
9db5d43e
exclude call and subscript expressions from has_own_parentheses
24e15bfd
avoid lambda special-casing in maybe_parenthesize_expression
0a41abed
ntBre
force pushed
from
40cbce56
to
7974b1c8
329 days ago
add some assignment tests with parentheses and comments
e9f9507d
add a couple more test cases
89dc1ada
ntBre
force pushed
from
7974b1c8
to
89dc1ada
329 days ago
use write!
18a3d593
create id only in indented case, update group name
972129c0
avoid nesting groups
2e950020
add too-eagerly parenthesized case from ecosystem
97850661
apply Micha's patch, fixing everything?
efa372b3
fix snapshot changes for cases with comments
6f6c09c7
fix another ecosystem call expansion
9ef9d030
use parenthesize_if_expands for fluent call chains
a3400a01
add wrapping case from the ecosystem check
258b1fd7
expand parent if the lambda body breaks
04963a6b
remove comment
7dddcc85
ntBre
marked this pull request as ready for review 328 days ago
ntBre
marked this pull request as draft 328 days ago
combine preview checks
afb01ce8
add comments and some supporting tests
2e84402f
copy mapper test case from can_omit_optional_parentheses
3a20c6f1
gate optional_parentheses branches behind stable
bdd5ba5e
Merge branch 'main' into brent/indent-lambda-params
1a3e385a
mirror comment handling from `maybe_parenthesize_expression`
08b1da3a
add some more tests
dfd3460c
check comment case first
219bbd1c
add another dangling eol case
a4b4a82e
improve dangling header comment placement
43b53edc
clippy
dc240a15
add another dangling case between lambda and parameters
5605387a
more tests
25d70b40
block indent and trailing comments
c7666423
leading_comments in block
fe255d1a
add more cases without parameters
8cbe03b3
try parenthesizing the body without parameters
c62390d1
Revert "try parenthesizing the body without parameters"
4585a0b3
factor out preview variable
3c481ba0
factor out parameters_have_comments
4d76cd7b
pairing
80852c17
wip
86406c0b
revert the last two commits, back to a stable formatting
1531c94b
fix assignment instability with dangling comments
0710e0bc
Reapply "try parenthesizing the body without parameters"
df42aa29
fix assignment instability without parameters too
f20f3e0d
move comments within lambda parameters to dangling lambda comments
8ede14a0
format new dangling comments
e8540d9b
ntBre
marked this pull request as ready for review 323 days ago
apply patch
c7b10896
clippy
ea30464a
accept snapshots
21b442a4
pass preview to handle_lambda_comment
711dd6ee
Merge branch 'main' into brent/indent-lambda-params
4ffbd496
add broken test cases
90f43bde
avoid breaking when the first parameter has leading comments
b0a82983
Merge branch 'brent/fix-kwargs' into brent/indent-lambda-params
65c94356
update snaps
fd34cd60
revert preview and comment placement changes
b8238661
revert FormatParameters changes
2bd64095
make comments leading on parameter_s_
d7221557
simplify check with parameters.start() == parameter.start()
f639389e
simplify a bit further
9d683da9
update comments
2da4798d
remove redundant parameters check
acc49ac1
update lambda comment
2e0ee2e0
Merge branch 'brent/fix-kwargs' into brent/indent-lambda-params
829f1052
clean up deref
54c76898
Merge branch 'main' into brent/indent-lambda-params
05ff8f5c
ntBre
commented
on 2025-12-09
ntBre
marked this pull request as draft 322 days ago
fix lambda formatting in assignments
bb053f83
factor out maybe_parenthesize_lambda
6e9e42d3
re-apply 'pass preview to handle_lambda_comment'
33fcca9c
move preview comment handling mostly into placement.rs
9f9b76b0
add preview function taking a PreviewMode
a8bebaa6
move tokenizer checks into the stable branch
f999da0e
update lambda placement docs
7c94e102
maybe_parenthesize_lambda -> maybe_parenthesize_value
8022343b
add a few more call tests with comments
b96cf96e
move dangling comment handling back out of placement.rs
553b45e2
factor out FormatBody
9d7d94c4
working for Micha's exact example
2cb98d4c
Revert leading comment changes
8711b1a3
reposition dangling comments
0f1ea90c
ntBre
marked this pull request as ready for review 320 days ago
save f.context.comments() to comments
5fee7534
share common code
d1b79f54
inline format_body
854062f8
delete outdated preview comments
6f255470
consolidate preview checks
00745159
unwrap format_body
3dfda9f6
inline current FormatBody
a48dc8ed
move all body formatting to FormatBody
b80fdfa1
inline parameters_have_comments
4a66edf5
share dangling comment logic
93a958a7
consolidate layout and preview checks
17a1065f
comment on leading_body_comments
d24895d4
improve dangling name and docs
3011190e
improve after_parameters_end_of_line name and docs
95301b3b
ntBre
merged
0ebdebdd
into main 319 days ago
ntBre
deleted the brent/indent-lambda-params branch 319 days ago
Assignees
No one assigned
Login to write a write a comment.
Login via GitHub