Skip to content

Misaligned comment in MultiLineBlockBracket #1716

Closed

Description

@Smaug123

Issue created from fantomas-online

Code

module I =
    let f =
        [
            ""
            // hi
        ]

Result

module I =
    let f =
        [
            ""
        // hi
        ]

Problem description

This is incredibly minor but I think the unindentation of the comment is aesthetically a bit sad. It would be more consistent for that comment to be indented one scope.

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas Master at 05/09/2021 13:45:10 - f10b822

    { config with
                SpaceBeforeUppercaseInvocation = true
                SpaceBeforeClassConstructor = true
                SpaceBeforeMember = true
                SpaceBeforeColon = true
                SpaceBeforeSemicolon = true
                MultilineBlockBracketsOnSameColumn = true
                AlignFunctionSignatureToIndentation = true
                AlternativeLongMemberDefinitions = true
                MultiLineLambdaClosingNewline = true
                KeepIndentInBranch = true }

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

Activity

  1. github-actions commented on Mar 30, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    Thanks for filing this, @Smaug123. The MultilineBlockBracketsOnSameColumn option has since been renamed/replaced by MultilineBracketStyle = Aligned, but the trivia indentation issue you describe — a line comment inside a list item appearing at the bracket level rather than the item level — is a known category of trivia handling bug in Fantomas.

    The root cause is that when the comment trivia is attached to the list item node in the Oak representation, the indentation context applied to the comment comes from the bracket scope rather than the item scope. This is a non-trivial fix in the trivia attribution logic in ASTTransformer.fs.

    The issue is still open and still relevant. If anyone wants to look at it, the place to start is how mkExprListOrArray in ASTTransformer.fs attributes trivia to list elements — specifically trailing comments on items before the closing bracket.

    Generated by 🌈 Repo Assist at {run-started}. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions