davidvarga/MBeautifier

Add rule to keep spacing of end of line comments

asparc opened this issue · 1 comments

First of all, thank you for making this code beautifier! It has been really useful so far.

I have one suggestion for an additional rule in the settings: keeping the spacing of end of line comments. An example of why this could be useful:

Input:

k_coeff = 0.5;              % [...] mass flow rate coefficient
area_table = 0.06;          % [m^2] (maximum) suction area of table
area_connection = 0.04;     % [m^2] crossection area of vessel connection
area_valve = 0.06;          % [m^2] (maximum) valve open area
q_pump = 0.85;              % [m^3/s] pump volumetric flow rate at maximum speed

Output of MBeautifier:

k_coeff = 0.5; % [...] mass flow rate coefficient
area_table = 0.06; % [m^2] (maximum) suction area of table
area_connection = 0.04; % [m^2] crossection area of vessel connection
area_valve = 0.06; % [m^2] (maximum) valve open area
q_pump = 0.85; % [m^3/s] pump volumetric flow rate at maximum speed

The beautifier removes the readable structure of the end of line comments here. It would be nice to have a rule to avoid this.

Hi!

Currently as a workaround you could use the MBeautiferDirective "Format" to disable formatting for that section in your code: https://github.com/davidvarga/MBeautifier#directives

% MBeautifierDirective:Format:Off
k_coeff = 0.5;              % [...] mass flow rate coefficient
area_table = 0.06;          % [m^2] (maximum) suction area of table
area_connection = 0.04;     % [m^2] crossection area of vessel connection
area_valve = 0.06;          % [m^2] (maximum) valve open area
q_pump = 0.85;              % [m^3/s] pump volumetric flow rate at maximum speed
% MBeautifierDirective:Format:On

I hope this suites you.

By the way, a new directive could be added, similar to the one I mentioned, which directive could be used to keep the white space count between the code and the comment parts of each line, however to mae it work properly, it is not easy to be done.