rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 301 forks source link

Indentation of comments #5905

Open AndreasMatthias opened 3 years ago

AndreasMatthias commented 3 years ago

[Rubberduck v2.5.2.5906]

There's an issue with indentation of comments.

Executing Rubberduck -> Indent -> Current Module on this code

' xxx: function foo()
' test

will indent the second line which should not happen.

' xxx: function foo()
    ' test
Vogel612 commented 3 years ago

The reason behind that is the fact that the indenter is a port of the old VB6 SmartIndenter which is not actually aware of the VBA grammar and instead uses a more ... "heuristic" approach which fails in circumstances like this.

I don't think it's viable to fix this in the current indenter setup, because the ported code is necessarily complex and the underlying approach will keep creating such issues.

Once the indenter is based on the Parser results (cf. #4251), this issue should no longer appear.