Skip to content

Commit

Permalink
Add additional test for cramped.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Dec 26, 2022
1 parent 89c0e09 commit 9da2d8f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Fantomas.Core/FormatConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type MultilineFormatterType =

static member OfConfigString(cfgString: string) =
match cfgString with
| "character_width" -> Some(box MultilineFormatterType.CharacterWidth)
| "number_of_items" -> Some(box MultilineFormatterType.NumberOfItems)
| "character_width" -> Some MultilineFormatterType.CharacterWidth
| "number_of_items" -> Some MultilineFormatterType.NumberOfItems
| _ -> None

type MultilineBracketStyle =
Expand Down Expand Up @@ -67,9 +67,9 @@ type EndOfLineStyle =

static member OfConfigString(eolString: string) =
match eolString with
| "lf" -> Some(EndOfLineStyle.LF)
| "lf" -> Some EndOfLineStyle.LF
| "cr" -> failwith "Carriage returns are not valid for F# code, please use one of 'lf' or 'crlf'"
| "crlf" -> Some(EndOfLineStyle.CRLF)
| "crlf" -> Some EndOfLineStyle.CRLF
| _ -> None

// NOTE: try to keep this list below in sync with the docs (e.g. Documentation.md)
Expand Down
19 changes: 19 additions & 0 deletions src/Fantomas.Tests/EditorConfigurationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,25 @@ fsharp_multiline_bracket_style = aligned

Assert.AreEqual(Aligned, config.MultilineBracketStyle)

[<Test>]
let ``fsharp_multiline_bracket_style = cramped`` () =
let rootDir = tempName ()

let editorConfig =
"""
[*.fs]
fsharp_multiline_bracket_style = cramped
"""

use configFixture =
new ConfigurationFile(defaultConfig, rootDir, content = editorConfig)

use fsharpFile = new FSharpFile(rootDir)

let config = EditorConfig.readConfiguration fsharpFile.FSharpFile

Assert.AreEqual(Cramped, config.MultilineBracketStyle)

[<Test>]
let ``fsharp_multiline_block_brackets_on_same_column = true`` () =
let rootDir = tempName ()
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas/EditorConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ let parseOptionsFromEditorConfig
match editorConfigProperties.TryGetValue(editorConfigName) with
| true, Number n -> n
| true, Boolean b -> b
| true, MultilineFormatterType mft -> mft
| true, MultilineFormatterType mft -> box mft
| true, EndOfLineStyle eol -> box eol
| true, BracketStyle bs -> box bs
| _ -> defaultValue)
Expand Down

0 comments on commit 9da2d8f

Please sign in to comment.