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
478 stars 75 forks source link

Non-beautiful space in front of sizes in arguments block #113

Open FlorianPfaff opened 2 years ago

FlorianPfaff commented 2 years ago

Hi, thanks for keeping up the good work on this useful tool! One concerning the arguments block: The code

arguments
    varname (2, 2) double
end

is changed into

arguments
    varname(2, 2) double
end

which is not "beautiful" if you ask me. I know where this comes from - the numbers are interpreted as indices. However, in this context, they are a description of the expected size of the matrix. I think keeping the space there would make the code more beautiful.

Thanks for considering,

Florian

anakinsleftleg commented 1 year ago

there is no way to for MBeautify to know that that space should be retained. varname isn't a keyword so it just thinks the indices next to it need to be right next to varname. I can't imagine a way for MBeautify to fix that, unless there was some extra logic to read a function's input arguments, and if there is an arguments block, then treat the variable names differently as desired.

FlorianPfaff commented 1 year ago

I acknowledge that this is work and am not saying anyone should do it - however, I do not think there would need to be an extra logic to parse input arguments. It should be enough to detect if one is in an arguments block and then look for lines starting with \n\t* *([A-Za-z_0-9]* *\([0-9]* *,[0-9]* *)\) * and ignore them (or turn multiple spaces into a single space to beautify it).

tulimid1 commented 1 year ago

FYI - This also happens in properties blocks.