davidvarga / MBeautifier

MBeautifier is a MATLAB source code formatter, beautifier. It can be used directly in the MATLAB Editor and it is configurable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect reformatting that breaks code

VorpalBlade opened this issue · comments

Using Matlab R2015b I had the following code fragment:

Q=0.7*diag([(.04)^2 (.04)^2]);

Using the installed shortcut the format the editor page results in:

Q = 0.7 * diag([(.04)^2(.04)^2]);

These code snippets are not equivalent. The space after the first ^2 is important.

I have not changed the default configuration for MBeautifier.

I have tested with the latest release of MBeautifier (v1.3.2) as well as the latest git revision as of writing this (c77308e). Both versions exhibit the issue.

For what is worth, this also happens for
Q = [1 (1)];
which turns into
Q = [1(1)];
This is also with the commit c77308e .

I guess it could be fixed by first adding commas between elements in a vector, and then fix the spacing.

Hello guys,

I just solved this issue which happen to be the same problem.

I close this issue as duplicate - if the problem is not fixed, please comment on this one and I will reopen it.

Thanks!

Sorry, I had to revert the commit(s), it casues something else to break - this issue is much trickier than I thought.

Fixed the problem once again using a different solution.