Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format selection #2272

Merged
merged 59 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8144e02
Remove unused functions in Trivia.fs.
nojaf May 20, 2022
557a80d
Add first proof of concept of FormatSelection.
nojaf May 20, 2022
ff3e7fd
Use mkSynExprNode for toplevel SynExpr nodes.
nojaf May 20, 2022
6f0d969
WIP tree shape
nojaf May 28, 2022
0dd892b
Refactor TriviaNodeAssigner to tree structure.
nojaf May 30, 2022
f6b341c
Find node in selection using tree format.
nojaf May 30, 2022
02548bc
Remove FileIndex check for rangeContainsRange.
nojaf Jun 3, 2022
0158041
Consider selection range when collecting trivia.
nojaf Jun 3, 2022
80f3a6f
Slowly restoring trivia again via tree structure.
nojaf Jun 3, 2022
909a618
Fix some more unit tests.
nojaf Jun 3, 2022
fba7e64
Remove SynComponentInfo_ as actual parent node.
nojaf Jun 10, 2022
eade50f
Remove SynValData_ as actual parent node.
nojaf Jun 10, 2022
beb8980
Use full range for SynField.
nojaf Jun 10, 2022
11a4129
Run the final continuation for Sequentials.
nojaf Jun 10, 2022
2eb3f17
Combined get/set members in a single node.
nojaf Jun 10, 2022
02113df
Include leading comments in the file range.
nojaf Jun 10, 2022
3b0ec7d
Collect all comments on single line.
nojaf Jun 10, 2022
ba11165
Use full range for ModuleOrNamespace.
nojaf Jun 10, 2022
0d87680
Print trivia for SynExpr.Const.
nojaf Jun 10, 2022
22c6a98
Add trivia after last child if nothing fits before.
nojaf Jun 10, 2022
b466bf3
Restore block comment in PostfixList.
nojaf Jun 10, 2022
724812a
Don't collect blank lines from zero range source code.
nojaf Jun 10, 2022
0a37edb
Print trivia after infix app in NewlineInfixApp.
nojaf Jun 10, 2022
57c1127
Stay within the boundaries of the source text.
nojaf Jun 10, 2022
131560b
Remove old test.
nojaf Jun 10, 2022
8edbdc8
Correct full range of SynExprRecordField.
nojaf Jun 10, 2022
4f7a714
Use SynExpr_Const for synExprToFsAstType.
nojaf Jun 10, 2022
69c0919
Include conditional directives in ParsedInput range.
nojaf Jun 11, 2022
3caf284
Remove SynTypeDefnRepr_ObjectModel as node.
nojaf Jun 11, 2022
bb06a77
Use correct SynModuleOrNamespaceSig_ kinds.
nojaf Jun 11, 2022
956cbc2
Print trivia for AnonRecordFieldName.
nojaf Jun 11, 2022
7be344d
Print trivia before anon record field at right column.
nojaf Jun 11, 2022
b42c1d4
Use parsedData from SynExpr.Lambda in AstTransformer.fs.
nojaf Jun 11, 2022
61add33
Print after trivia for same infix application.
nojaf Jun 11, 2022
5083b30
Combine NewlineInfixApps and SameInfixApps under a single parent node.
nojaf Jun 11, 2022
22ec136
Add newline when attribute contains comment.
nojaf Jun 11, 2022
1716af1
Print trivia for SynPat.Or.
nojaf Jun 11, 2022
55ceb5d
Add children of valSig node to SynMemberSig.Member.
nojaf Jun 11, 2022
cba7064
Remove duplicate SynType_Paren.
nojaf Jun 11, 2022
59bd3bd
Duplicate with/and keyword in SynMemberDefn.Member.
nojaf Jun 11, 2022
d3ca601
Take the smallest possible trivia node for comment after source code.
nojaf Jun 11, 2022
2f38144
Print leading newlines when formatting a selection.
nojaf Jun 11, 2022
74157b4
Revisit trivia type names.
nojaf Jun 15, 2022
6ba9350
Clean up Trivia.fs.
nojaf Jun 15, 2022
d7c2b91
Remove SynTypeDefnSigRepr_ObjectModel type.
nojaf Jun 16, 2022
3ae8a4f
Use last node inside SynExpr.App to assign trivia after to.
nojaf Jun 16, 2022
cdaf747
Update to SynAccess range commit from fork.
nojaf Jun 16, 2022
821c143
Print trivia for keyword in union and record declarations.
nojaf Jun 16, 2022
f410606
Take the smallest node after.
nojaf Jun 24, 2022
a55c246
Update compiler to "Add arrow to SynType.Fun trivia".
nojaf Jun 24, 2022
a915c6c
Add trivia after arrow in SynType.Fun.
nojaf Jun 24, 2022
dda00cf
Add regression tests from dotnet/fsharp.
nojaf Jun 24, 2022
8992c25
Trim the selection to the first code positions. Try and format that e…
nojaf Jun 24, 2022
cffcfc5
Format certain selections in signature files.
nojaf Jun 24, 2022
003747f
Correct typos and introduce signature file for Selection.fs
nojaf Jun 25, 2022
1ba7758
Reestablish format selection in Daemon.
nojaf Jun 25, 2022
5e6fe45
Don't return option for FormatSelection API, try and be consistent wi…
nojaf Jun 25, 2022
81b283a
Add documentation for selection api.
nojaf Jun 25, 2022
e5d3040
Clean up.
nojaf Jun 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,25 @@ Note that Fantomas only searches for a `.fantomasignore` file in or above its cu

## Using the API

See [CodeFormatter.fsi](../src/Fantomas/CodeFormatter.fsi) to view the public API of Fantomas.
See [CodeFormatter.fsi](../src/Fantomas.Core/CodeFormatter.fsi) to view the public API of Fantomas.

### Format selection

Fantomas provides limited support for formatting a selection of code in a file, using the `CodeFormatter.FormatSelectionAsync` function.
This is a very challenging domain, so not every scenario is covered.
Fantomas is able to format:
- Top-level declarations like [SynModuleDecl](https://fsharp.github.io/fsharp-compiler-docs/reference/fsharp-compiler-syntax-synmoduledecl.html) and [SynModuleSigDecl](https://fsharp.github.io/fsharp-compiler-docs/reference/fsharp-compiler-syntax-synmodulesigdecl.html).
- Expressions like [SynExpr](https://fsharp.github.io/fsharp-compiler-docs/reference/fsharp-compiler-syntax-synexpr.html)
- 'val' definitions like [SynValSig](https://fsharp.github.io/fsharp-compiler-docs/reference/fsharp-compiler-syntax-synvalsig.html)

The selection can have leading or trailing spaces but an exact selection is recommended.
Invalid selections where no matching AST node is found will result in an exception.
The return value of the function is the formatted code and the range of the formatted AST node.
If the input selection range contained whitespaces, the result selection will contain the exact range of the formatted AST node.

Please consider contributing to this feature if you encounter any issues.

```fsharp

## A git pre-commit hook sample

Expand Down
178 changes: 89 additions & 89 deletions paket.dependencies

Large diffs are not rendered by default.

180 changes: 90 additions & 90 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,96 +171,96 @@ NUGET
GITHUB
remote: fsprojects/fantomas
src/Fantomas/CodePrinter.fs (829faa6ba834f99afed9b4434b3a1680536474b2)
remote: dotnet/fsharp
src/Compiler/AbstractIL/il.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/il.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilascii.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilascii.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/illex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/illex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilpars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilpars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilx.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/AbstractIL/ilx.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/DiagnosticOptions.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/DiagnosticOptions.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/DiagnosticsLogger.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/DiagnosticsLogger.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/LanguageFeatures.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/LanguageFeatures.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/Logger.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/Logger.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/prim-lexing.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/prim-lexing.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/prim-parsing.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/prim-parsing.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/TextLayoutRender.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/TextLayoutRender.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Facilities/UtilsStrings.txt (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/FSComp.txt (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/FSStrings.resx (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Interactive/FSIstrings.txt (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/lex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/lex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pplex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pplex.fsl (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pppars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/pppars.fsy (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/LexFilter.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/LexFilter.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/LexHelpers.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/LexHelpers.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/ParseHelpers.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/ParseHelpers.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/PrettyNaming.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/PrettyNaming.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTree.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTree.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTreeOps.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTreeOps.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTrivia.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/SyntaxTrivia.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/UnicodeLexing.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/UnicodeLexing.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/XmlDoc.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/SyntaxTree/XmlDoc.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/FileSystem.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/FileSystem.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/HashMultiMap.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/HashMultiMap.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/ildiag.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/ildiag.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/illib.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/illib.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/InternalCollections.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/InternalCollections.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/lib.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/lib.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/PathMap.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/PathMap.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/QueueList.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/QueueList.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/range.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/range.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/rational.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/rational.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/ResizeArray.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/ResizeArray.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/RidHelpers.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/sformat.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/sformat.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/sr.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/sr.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/TaggedCollections.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/TaggedCollections.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/XmlAdapters.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/XmlAdapters.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/zmap.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/zmap.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/zset.fs (b822e2793bd6387c40cfd5b25d604e002a253257)
src/Compiler/Utilities/zset.fsi (b822e2793bd6387c40cfd5b25d604e002a253257)
remote: nojaf/fsharp
src/Compiler/AbstractIL/il.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/il.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilascii.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilascii.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/illex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/illex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilpars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilpars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilx.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/AbstractIL/ilx.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/DiagnosticOptions.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/DiagnosticOptions.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/DiagnosticsLogger.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/DiagnosticsLogger.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/LanguageFeatures.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/LanguageFeatures.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/Logger.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/Logger.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/prim-lexing.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/prim-lexing.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/prim-parsing.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/prim-parsing.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/TextLayoutRender.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/TextLayoutRender.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Facilities/UtilsStrings.txt (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/FSComp.txt (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/FSStrings.resx (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Interactive/FSIstrings.txt (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/lex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/lex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pplex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pplex.fsl (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pppars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/pppars.fsy (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/LexFilter.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/LexFilter.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/LexHelpers.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/LexHelpers.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/ParseHelpers.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/ParseHelpers.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/PrettyNaming.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/PrettyNaming.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTree.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTree.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTreeOps.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTreeOps.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTrivia.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/SyntaxTrivia.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/UnicodeLexing.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/UnicodeLexing.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/XmlDoc.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/SyntaxTree/XmlDoc.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/FileSystem.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/FileSystem.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/HashMultiMap.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/HashMultiMap.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/ildiag.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/ildiag.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/illib.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/illib.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/InternalCollections.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/InternalCollections.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/lib.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/lib.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/PathMap.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/PathMap.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/QueueList.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/QueueList.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/range.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/range.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/rational.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/rational.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/ResizeArray.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/ResizeArray.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/RidHelpers.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/sformat.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/sformat.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/sr.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/sr.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/TaggedCollections.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/TaggedCollections.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/XmlAdapters.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/XmlAdapters.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/zmap.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/zmap.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/zset.fs (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
src/Compiler/Utilities/zset.fsi (0f1a901cb7fd93dd32f051ceb364247cb9218fc9)
GROUP build
STORAGE: NONE
NUGET
Expand Down
5 changes: 5 additions & 0 deletions src/Fantomas.Client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This is the changelog for the Fantomas.Client package specifically. It's distinct from that of the overall libraries and command-line tool.

## [Unreleased]

### Changed
* Add `SelectedRange` to `FantomasResponse`.

## 0.5.4 - 2022-05-06

* FSharp.Core 5.0.1 or higher. [#2227](https://github.com/fsprojects/fantomas/pull/2227)
Expand Down
16 changes: 12 additions & 4 deletions src/Fantomas.Client/Contracts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ type FormatDocumentRequest =
Config: IReadOnlyDictionary<string, string> option
}

type FantomasResponse =
{ Code: int
FilePath: string
Content: string option }
member this.IsSignatureFile = this.FilePath.EndsWith(".fsi")

type FormatSelectionRequest =
{
Expand All @@ -45,6 +42,7 @@ type FormatSelectionRequest =
/// Range follows the same semantics of the FSharp Compiler Range type.
Range: FormatSelectionRange
}
member this.IsSignatureFile = this.FilePath.EndsWith(".fsi")

and FormatSelectionRange =
struct
Expand All @@ -60,6 +58,16 @@ and FormatSelectionRange =
EndColumn = endColumn }
end

type FantomasResponse =
{
Code: int
FilePath: string
Content: string option
/// The actual range that was used to format a selection.
/// This can differ from the input selection range if the selection had leading or trailing whitespace.
SelectedRange: FormatSelectionRange option
}

type FantomasService =
interface
inherit IDisposable
Expand Down
Loading