hilkoc / vbaDeveloper

Tools for development and version control of vba code
MIT License
516 stars 137 forks source link

wrong indentation after code formatting #45

Closed yarick123 closed 4 years ago

yarick123 commented 4 years ago

code like

    Do Until (rs.State = adStateOpen): Set rs = rs.NextRecordset: Loop
    If (rs.Fields.count < 1 Or rs.Fields(0).Name <> "VERSION") Then
        Err.Raise Number:=vbObjectError + 500, Description:="Cannot read server side API version number"
    End If

is formatted to

    Do Until (rs.State = adStateOpen): Set rs = rs.NextRecordset: Loop
        If (rs.Fields.count < 1 Or rs.Fields(0).Name <> "VERSION") Then
            Err.Raise Number:=vbObjectError + 500, Description:="Cannot read server side API version number"
        End If

As a solution I propose the patch https://github.com/hilkoc/vbaDeveloper/pull/44. It introduces a constant SIMPLIFIED_FORMAT, initialized with False by default. If it is set to True, the code formatting will be reduced just to trimming trailing spaces of each code line.

hilkoc commented 4 years ago

The problem here is that the whole loop is written on a single line. The code formatter is not prepared for that situation. I'd be happy to take a pull request for a fix for that.

Just disabling the indentation makes the code formatting pointless.

Write the 'Loop' keyword on a single line of its own. Then the formatter will apply the correct indentation.