Skip to content

Commit b162c47

Browse files
authored
Avoid excessive formatting in for/fold suggestion (#476)
1 parent 15d4263 commit b162c47

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

default-recommendations/for-loop-shortcuts-test.rkt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,36 @@ test: "multi-accumulator for/fold with one used result refactorable to for/fold
447447
------------------------------
448448

449449

450+
test: "multi-accumulator for/fold with one used result refactorable without formatting surroundings"
451+
------------------------------
452+
(define (foo)
453+
( displayln "foo" )
454+
455+
(define-values (x y z)
456+
(for/fold ([accum1 0]
457+
[accum2 0]
458+
[accum3 0])
459+
([n (in-naturals)])
460+
(values 0 0 0)))
461+
462+
(* x 2))
463+
------------------------------
464+
------------------------------
465+
(define (foo)
466+
( displayln "foo" )
467+
468+
(define x
469+
(for/fold ([accum1 0]
470+
[accum2 0]
471+
[accum3 0]
472+
#:result accum1)
473+
([n (in-naturals)])
474+
(values 0 0 0)))
475+
476+
(* x 2))
477+
------------------------------
478+
479+
450480
test: "for/fold with conditional body refactorable to for/fold with #:when"
451481
------------------------------
452482
(define (foo)

default-recommendations/for-loop-shortcuts.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ return just that result."
336336
(for-id ([accumulator-id initializer] ...
337337
#:result #,used-accumulator)
338338
loop-clauses loop-body ...))
339+
339340
(body-before ...
340-
(~replacement replacement-definition #:original original-definition)
341+
(~focus-replacement-on (~replacement replacement-definition #:original original-definition))
341342
body-after ...))
342343

343344

0 commit comments

Comments
 (0)