Skip to content

Commit fab1bd8

Browse files
authored
Merge pull request #3170 from nojaf/fix-1999
Check if application and idx are actually multiline.
2 parents 51fade1 + 04d902f commit fab1bd8

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 7.0.3 - 2025-07-04
4+
5+
### Fixed
6+
7+
* Application in indexed set should not be multiline. [#1999](https://github.com/fsprojects/fantomas/issues/1999)
8+
39
## 7.0.2 - 2025-05-27
410

511
### Changed

src/Fantomas.Core.Tests/NewlineBeforeMultilineComputationExpressionTests.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ app(meh).[x] <-
6363
|> should
6464
equal
6565
"""
66-
app(
67-
meh
68-
).[x] <- task {
66+
app(meh).[x] <- task {
6967
// some computation here
7068
()
7169
}

src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,7 @@ app(meh).[x] <-
290290
|> should
291291
equal
292292
"""
293-
app(
294-
meh
295-
).[x] <- {
293+
app(meh).[x] <- {
296294
A = longTypeName
297295
B = someOtherVariable
298296
C = ziggyBarX
@@ -311,9 +309,7 @@ app(meh).[x] <-
311309
|> should
312310
equal
313311
"""
314-
app(
315-
meh
316-
).[x] <- {
312+
app(meh).[x] <- {
317313
astContext with
318314
IsInsideMatchClausePattern = true
319315
}
@@ -333,9 +329,7 @@ app(meh).[x] <-
333329
|> should
334330
equal
335331
"""
336-
app(
337-
meh
338-
).[x] <- {|
332+
app(meh).[x] <- {|
339333
A = longTypeName
340334
B = someOtherVariable
341335
C = ziggyBarX
@@ -357,9 +351,7 @@ app(meh).[x] <-
357351
|> should
358352
equal
359353
"""
360-
app(
361-
meh
362-
).[x] <- struct {|
354+
app(meh).[x] <- struct {|
363355
A = longTypeName
364356
B = someOtherVariable
365357
C = ziggyBarX
@@ -382,9 +374,7 @@ app(meh).[x] <-
382374
|> should
383375
equal
384376
"""
385-
app(
386-
meh
387-
).[x] <- [
377+
app(meh).[x] <- [
388378
itemOne
389379
itemTwo
390380
itemThree
@@ -409,9 +399,7 @@ app(meh).[x] <-
409399
|> should
410400
equal
411401
"""
412-
app(
413-
meh
414-
).[x] <- [|
402+
app(meh).[x] <- [|
415403
itemOne
416404
itemTwo
417405
itemThree

src/Fantomas.Core/CodePrinter.fs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,18 @@ let genExpr (e: Expr) =
14481448
let genDotIndexedSetWithApp funcExpr argExpr (appNode: Node) =
14491449
let short = funcExpr +> genExpr argExpr |> genNode appNode
14501450

1451-
let long =
1452-
funcExpr +> genMultilineFunctionApplicationArguments argExpr |> genNode appNode
1453-
14541451
let idx =
14551452
!-"." +> sepOpenLFixed +> genExpr node.Index +> sepCloseLFixed +> sepArrowRev
14561453

1454+
let long ctx =
1455+
let multiline =
1456+
funcExpr +> genMultilineFunctionApplicationArguments argExpr |> genNode appNode
1457+
1458+
if futureNlnCheck (short +> idx) ctx then
1459+
multiline ctx
1460+
else
1461+
short ctx
1462+
14571463
expressionFitsOnRestOfLine
14581464
(short +> idx +> genExpr node.Value)
14591465
(long

0 commit comments

Comments
 (0)