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

Indentation removed when combining comments and compiler directives #382

Closed
alfonsogarciacaro opened this issue Dec 10, 2018 · 1 comment

Comments

@alfonsogarciacaro
Copy link
Contributor

Issue created from fantomas-ui

This is a very weird combination of circumstances so not sure if it's fixable. Please look at the example below, after formatting, private loses indentation so the code doesn't compile (and in this case, it only showed up in Fable compilation with apparently unrelated errors so it was a bit difficult to spot it). The interesting part is this only happens when using both the comments between the type name and private keyword and the compiler directive. If you remove any of the two, the formatting is done correctly. Does it ring a bell? If it doesn't, don't worry too much as this will happen very rarely (though in cases like this it may be a good idea to leave the formatting of code between compiler directives untouched).

Code

type Currency =
    // TODO: Temporary fix until a new Thoth.Json.Net package is released
    // See https://github.com/MangelMaxime/Thoth/pull/70

#if FABLE_COMPILER
    private
#endif
    | Code of string

Error

type Currency = // TODO: Temporary fix until a new Thoth.Json.Net package is released
                // See https://github.com/MangelMaxime/Thoth/pull/70

#if FABLE_COMPILER
private
#endif
    Code of string

Options

Fantomas 2.9.1

Name Value
IndentSpaceNum 4
PageWidth 80
PreserveEndOfLine false
SemicolonAtEndOfLine false
SpaceBeforeArgument true
SpaceBeforeColon true
SpaceAfterComma true
SpaceAfterSemicolon true
IndentOnTryWith false
ReorderOpenDeclaration false
SpaceAroundDelimiter true
StrictMode false
@nojaf
Copy link
Contributor

nojaf commented Dec 10, 2018

I'm guessing something is wrong in TokenMatcher code. Perhaps setting PreserveEndOfLine to true helps as workaround, but that might lead to other surprises 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants