Skip to content

Comment is not aligned with trailing comment on previous line any more #1134

Closed

Description

@Manuel-MM

Release 0.64 introduces a behaviour that reformatted comments in files that I had already uncrustified. Comments are not aligned with previous trailing comments that follow a preprocessor directive. Comments that were previously aligned, like this:

#define ABC 123 // Start trailing comment..
                // ..end with aligned comment.

in 0.64 now are set to column 0 and become:

#define ABC 123 // Start trailing comment..
// ..end with aligned comment.

I bisected this down to commit 0092f3d, and the commit message says it is a rule-3 fix. But I can't see where this is a fix. It should be taken back. Or is there an option to get the familiar alignment back? Please advise.

Activity

  1. mihaipopescu commented on May 2, 2017

    @mihaipopescu
    Collaborator

    The "rule-3" of comment comment alignment was dealing with comments relatively close to each other (within a 3 column distance). The change you mention was made to defend against another unwanted behavior (in the test) and unfortunately it was not guarded by another option for you to easily deactivate it.

    That fix is regressing your case (unknown to present) and we should find a proper way to fix it.

    some ideas:

    1. add a configurable threshold (now hard-coded at 3)
    2. have another rule to disable the "rule-3" entirely
    3. have another rule to disable "rule-3" in the case of a preproc (maybe how the initial change should've been implemented)
  2. Manuel-MM commented on May 2, 2017

    @Manuel-MM
    Author

    Thanks for the quick reply!
    Personally, I am happy with a hard-coded three-column threshold and have no need to disable the "rule-3" at all. But I don't know what the other unwanted behaviour in the test was, so I can't make a qualified suggestion.

  3. mihaipopescu commented on May 3, 2017

    @mihaipopescu
    Collaborator

    The unwanted behavior was that it added an unwanted extra alignment with Doxygen member groups end marker when it was proceeded by a preproc:

     class MyClass : public BaseClass
     {
         //@{ BaseClass interface
     #if VERY_LONG_AND_COMPLICATED_DEFINE
         void foo();
     #endif // VERY_LONG_AND_COMPLICATED_DEFINE
    -    //@}
    +       //@}
     };
  4. Manuel-MM commented on May 3, 2017

    @Manuel-MM
    Author

    Oh, that's interesting! I couldn't have thought of that, I didn't use Doxygen so far. I think your idea number two is most straigtforward. But maybe some Doxygen users would still want to use rule-3 after a preproc (if not near member group marker). So, I'd like to throw in:

    1. have another rule to disable rule-3 for Doxygen markers "//@}" and "//@{"
  5. mihaipopescu commented on May 4, 2017

    @mihaipopescu
    Collaborator

    That could work as well, but I would also fix it by making Doxygen markers to have 3 comment slashes instead of 2 which will cross the 3 column boundary of rule-3. Could be an option.

  6. Manuel-MM commented on May 4, 2017

    @Manuel-MM
    Author

    I went through the source code to find a function that would help to detect the Doxygen markers, but it's the first time I'm looking at it and will take me more time. I could give it another try next week.

  7. guy-maurel commented on Jun 2, 2017

    @guy-maurel
    Contributor

    which are the Doxygen markers?

  8. guy-maurel commented on Jun 4, 2017

    @guy-maurel
    Contributor

    No!
    Version 0.63 has the same.
    Please push your configuration, it might be the problem.

  9. self-assigned this
    on Jun 4, 2017
  10. Manuel-MM commented on Jun 4, 2017

    @Manuel-MM
    Author

    I just downloaded the 0.63 binary from sourceforge again and checked with config file linux.cfg. I definitely don't have the problem there, the alignment is kept in 0.63.

  11. guy-maurel commented on Jun 10, 2017

    @guy-maurel
    Contributor

    I am working on it.

  12. added a commit that references this issue on Jun 13, 2017
  13. guy-maurel commented on Jun 13, 2017

    @guy-maurel
    Contributor

    A proposal for a bugfix is #1205

  14. gmaurel commented on Jun 14, 2017

    @gmaurel
    Collaborator

    The bug is fixed

  15. added a commit that references this issue on Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions