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

Worng indentation with formatFileNoEditor #121

Open Wave89 opened 1 year ago

Wave89 commented 1 year ago

if there keywords like "if", "while", "for", "function" in comments (e.g. "% this should be done while ...") , strings (e.g. variable1 ="while the sun is shining") or commands (e.g. "dbstop if error") the function formatFileNoEditor is not working properly with indentation.

RodneyRichardson commented 8 months ago

Similarly, it doesn't get the end correct (indents it too far).

WORKAROUND: Use the formatFile function instead,

ehennestad commented 3 weeks ago

Need to exclude words here that are part of a string: https://github.com/davidvarga/MBeautifier/blob/0f90feb8fd5b93185eabfdaaa6abf26bf6cda7d0/%2BMBeautifier/MIndenter.m#L70