Skip to content

Commit

Permalink
Merge branch 'main' into update_analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Dec 6, 2023
2 parents 78289ae + 862e33c commit e57ad00
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Changelog

## Unreleased
## 6.3.0-alpha-004 - 2023-12-06

### Fixed
* Process is reserved keyword. [#2996](https://github.com/fsprojects/fantomas/issues/2996)
* Always yield list items on separate lines if a conditional is present. [#2972](https://github.com/fsprojects/fantomas/issues/2972)
* Trivia after mutable keyword is missing. [#3005](https://github.com/fsprojects/fantomas/issues/3005)
* Formatting can depend on cursor position. [#3007](https://github.com/fsprojects/fantomas/issues/3007)

### Changed
* Update FCS to 'Parser: recover on unfinished record decls, fix field ranges ', commit ee4a810ffe9e984e2ec8c55a9cb6d1c6631dd0b3 [#3006](https://github.com/fsprojects/fantomas/pull/3006)
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Some common use cases include:
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
<ServerGarbageCollection>true</ServerGarbageCollection>
<LangVersion>preview</LangVersion>
<OtherFlags>$(OtherFlags) --test:GraphBasedChecking --test:ParallelOptimization --test:ParallelIlxGen</OtherFlags>
<OtherFlags>$(OtherFlags) --test:GraphBasedChecking --test:ParallelOptimization --test:ParallelIlxGen --strict-indentation+</OtherFlags>
</PropertyGroup>

<!-- Versions -->
Expand Down
15 changes: 15 additions & 0 deletions src/Fantomas.Core.Tests/CursorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,18 @@ type FSharpReformatCode(textControlManager: ITextControlManager) =
"""
(8, 19)
|> assertCursor (7, 15)

[<Test>]
let ``cursor should not be considered as content before, 3007`` () =
let result =
formatWithCursor
"""pipeline "init" {
stage "restore-sln" {
parallel
run "dotnet tool restore"
}
}
"""
(4, 0)

result |> assertCursor (4, 0)
22 changes: 20 additions & 2 deletions src/Fantomas.Core/SyntaxOak.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,27 @@ type NodeBase(range: range) =
let nodesAfter = Queue<TriviaNode>(0)

member _.ContentBefore: TriviaNode seq = nodesBefore
member _.HasContentBefore = not (Seq.isEmpty nodesBefore)

member _.HasContentBefore =
nodesBefore
|> Seq.filter (fun tn ->
match tn.Content with
| Cursor -> false
| _ -> true)
|> Seq.isEmpty
|> not

member _.ContentAfter: TriviaNode seq = nodesAfter
member _.HasContentAfter = not (Seq.isEmpty nodesAfter)

member _.HasContentAfter =
nodesAfter
|> Seq.filter (fun tn ->
match tn.Content with
| Cursor -> false
| _ -> true)
|> Seq.isEmpty
|> not

member _.Range = range
member _.AddBefore triviaNode = nodesBefore.Enqueue triviaNode
member _.AddAfter triviaNode = nodesAfter.Enqueue triviaNode
Expand Down

0 comments on commit e57ad00

Please sign in to comment.