fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
770 stars 191 forks source link

Incorrect indentation of compiler-conditional accessibility modifier for module definition #2867

Closed roboz0r closed 1 year ago

roboz0r commented 1 year ago

Issue created from fantomas-online

Code

module
#if DEBUG
#else
    internal
#endif
    A = 
        let f x = x + x

Result

module
#if DEBUG
#else
internal
#endif
A =
    let f x = x + x

Problem description

As can be seen above, the correct indentation isn't maintained for the accessibility modifier or module name when surrounded by compiler conditionals. The below alternative is a successful workaround:

#if DEBUG
module A =
#else
module internal A =
#endif

Extra information

Options

Fantomas main branch at 1/1/1990 <- incorrect date is shown on the online editor

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

dawedawe commented 1 year ago

Hello @roboz0r, thanks for opening this issue. We handle this correctly for types, but as you see, not for modules. Maybe this gets you going in the right direction to fix this yourself. Most likely we would need to apply the same trick here as for types.

Are you interested in submitting a PR for this?

dawedawe commented 1 year ago

To help a bit more, you'd need to do the same as in the fix for #628 but here