davidvarga / MBeautifier

MBeautifier is a MATLAB source code formatter, beautifier. It can be used directly in the MATLAB Editor and it is configurable.
GNU General Public License v3.0
483 stars 77 forks source link

trailing whitespace in indented blocks #96

Closed casperdcl closed 3 years ago

casperdcl commented 3 years ago

blank lines within an indented block should be blank rather than indented (pure whitespace).

diff (-before +after):

 if 1
     display('first line, with a blank line below');
-    
+
     display('second line, with a blank line above');
 end

this will also make MBeautify compatible with https://github.com/pre-commit/pre-commit-hooks#trailing-whitespace and many code editors which auto-strip trailing whitespace regardless of indentation context.

Looks like this is the line which needs to be implemented:

https://github.com/davidvarga/MBeautifier/blob/4087074c1221c3748c29278fb0cca1c6f3681605/%2BMBeautifier/MIndenter.m#L47-L48