Skip to content

Formatting document removes '#if DEBUG' and '#endif' #512

Closed
@mandrolic

Description

Description

(Punted from Ionide issue ionide/ionide-vscode-fsharp#1246)

Encountered when saving a file in a Fable/Elmish project which has this construct, where parts of a piped expression are switched in when in DEBUG:

Program.mkProgram init update view
|> Program.toNavigable parser setRoute
|> Program.withConsoleTrace
#if DEBUG
|> Program.withHMR
#endif
|> Program.withReact "elmish-app"
#if DEBUG
|> Program.withDebugger
#endif
|> Program.run

When formatting, this gets changed to:

Program.mkProgram init update view
|> Program.toNavigable parser setRoute
|> Program.withConsoleTrace
|> Program.withHMR
|> Program.withReact "elmish-app"
|> Program.withDebugger
|> Program.run

To Reproduce
Steps to reproduce the behaviour:

  1. Create a fs file with this code:
let foo = [ 1 ]
            |> List.sort
#if DEBUG
            |> List.rev
#endif
            |> List.sort
  1. Execute Format Code, or save the file if format on save is enabled

Expected behaviour
Directives are left untouched

Environment (please complete the following information):

  • OS: Win 10 1903
  • Ionide version: 4.2.0
  • VSCode version: 1.39.1
  • dotnet SDK version: 2.2
  • mono / .Net Framework version:

Repro code

https://jindraivanek.gitlab.io/fantomas-ui/#?code=DYUwLgBAZg9jEF4IG0IEYIF0CwAoCBhRBAPgHwQAyAlgM5gB0tMATmHgMTVQQAiAogCEAqgHE8xSRHJU6jFiABunEADsAJtwlSiMmvSat2+KUA

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions