diff --git a/src/Fantomas.Core/FormatConfig.fs b/src/Fantomas.Core/FormatConfig.fs index 0148806c1a..a6b201821b 100644 --- a/src/Fantomas.Core/FormatConfig.fs +++ b/src/Fantomas.Core/FormatConfig.fs @@ -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 = @@ -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) diff --git a/src/Fantomas.Tests/EditorConfigurationTests.fs b/src/Fantomas.Tests/EditorConfigurationTests.fs index 03439600cb..55854ed8d5 100644 --- a/src/Fantomas.Tests/EditorConfigurationTests.fs +++ b/src/Fantomas.Tests/EditorConfigurationTests.fs @@ -504,6 +504,25 @@ fsharp_multiline_bracket_style = aligned Assert.AreEqual(Aligned, config.MultilineBracketStyle) +[] +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) + [] let ``fsharp_multiline_block_brackets_on_same_column = true`` () = let rootDir = tempName () diff --git a/src/Fantomas/EditorConfig.fs b/src/Fantomas/EditorConfig.fs index 77be04694a..a0751a4cc3 100644 --- a/src/Fantomas/EditorConfig.fs +++ b/src/Fantomas/EditorConfig.fs @@ -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)