In MATLAB R2021b the MBeautify.formatCurrentEditorPage() and MBeautify.formatEditorSelection() functions didn't indent the code correctly anymore. It seems to be a bug in MathWorks' editorPage.smartIndentContents() function which gets triggered depending on the cursor position in the editor.
This pull request fixes the issue by indenting the code before restoring the cursor position. This was anyway a bug in the MBeautifier code, because the smart indentation resets the cursor position, making its prior restoration pointless.
The pull request also contains another improvement to the cursor restoration and a bugfix for the MBeautify.formatEditorSelection() function.
In MATLAB R2021b the
MBeautify.formatCurrentEditorPage()
andMBeautify.formatEditorSelection()
functions didn't indent the code correctly anymore. It seems to be a bug in MathWorks'editorPage.smartIndentContents()
function which gets triggered depending on the cursor position in the editor.This pull request fixes the issue by indenting the code before restoring the cursor position. This was anyway a bug in the MBeautifier code, because the smart indentation resets the cursor position, making its prior restoration pointless.
The pull request also contains another improvement to the cursor restoration and a bugfix for the
MBeautify.formatEditorSelection()
function.