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 indentation in nest for loop

zousiyu1995 opened this issue · comments

As shown in figure below,
image

Cannot reproduce, but also depends on using whitespace or tabs and Matlab version. Actually there are various other indentation issues and they seem to originate form an incorrect interaction between MBeauttify's IndentationCount setting and Matlab's own settings (Preferences-Editor/Debugger->Tab). Changing line 372 in MBeautify to

skipIndentation = true;

which lets Matlab do all indentation, without MBeautify changing it afterwards, seems to work ok for me on R2021b.

edit also there's a difference between using formatFile and formatFileNoEditor, the latter indeed producing errors like you show.

I have the same issue as OP. I'm on 21b, my editor tabs are spaces and set for 2. Same settings in MBeautify config. I get the same outcome when run on an open file in the editor.

~~Update: I upgraded from 1.3.1 to 1.3.2 and it no longer behaves that way. ~~

Update 2: Actually, it just happened again. No idea what the conditions are on this happening.

Looks like i'll be using @stinos fork