Skip to content

Formatter incorrectly moves comments outside of function body #184

@graddotdev

Description

@graddotdev

The redscript formatter is exhibiting unintended behavior when handling comments placed within a function's body. Instead of preserving the comments' original placement, the formatter moves them outside of the function block, which can alter the code's readability and intended documentation.

Steps to Reproduce:

  1. Create a redscript file with the following code:
    func Test() {
      1 + 2;
      // Comment 1
      // Comment 2
    }
    
  2. Run the redscript formatter on this file.

Expected Behavior:

The formatter should preserve the comments' position within the function, resulting in the following code:

func Test() {
  1 + 2;
  // Comment 1
  // Comment 2
}

Actual Behavior:

The formatter incorrectly moves the comments to after the function block, producing this output:

func Test() {
  1 + 2;
}

// Comment 1
// Comment 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions