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

Comment between objects (or nodes in general) #291

Open
nmigueles opened this issue Sep 29, 2024 · 2 comments
Open

Comment between objects (or nodes in general) #291

nmigueles opened this issue Sep 29, 2024 · 2 comments
Labels
component: parser priority: low A nice to have, or not so important issue

Comments

@nmigueles
Copy link
Contributor

Made a test to check this behavior

image

But long story short, if i want to comment something between some parts of the code, the comment is formatted to the end of the last node (as if it was a inline comment)

How to reproduce

object foo {
    var hp = 0
}
          
// comment

object bar {
    var hp = 0
}

Formats to:

object foo {
    var hp = 0
} // comment

object bar {
    var hp = 0
}

This was annoying while making the assignment and trying to comment which student was reponsible or like commenting the actual exercise statement.

@nmigueles
Copy link
Contributor Author

Its not exclusive to objects, happens with classes too

class Foo {
    var hp = 0
}
          
// comment

class Bar {
    var hp = 0
}

Formats to:

class Foo {
    var hp = 0
}  // comment

class Bar {
    var hp = 0
}

@PalumboN
Copy link
Contributor

PalumboN commented Oct 4, 2024

Haha I would expect this result

class Foo {
    var hp = 0
}  

// comment

class Bar {
    var hp = 0
}

So, probably this means that the comment is parsed as part of the first node (as "end" comment).

The formatter now is ignoring the original spaces in the code... Maybe we should check that logic.

It's a good test to add. Thanks!

@PalumboN PalumboN added component: parser priority: low A nice to have, or not so important issue labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: parser priority: low A nice to have, or not so important issue
Projects
None yet
Development

No branches or pull requests

2 participants