mathworks / MATLAB-extension-for-vscode

This extension provides support for editing MATLAB® code in Visual Studio® Code and includes features such as syntax highlighting, code analysis, navigation support, and more.
https://marketplace.visualstudio.com/items?itemName=MathWorks.language-matlab
MIT License
241 stars 16 forks source link

Can choose a single formatting style. #176

Closed relifenoxiao closed 2 months ago

relifenoxiao commented 2 months ago

new feature

I wanna be able to choose a single formatting style.

reason

I prefer to use the C style for formatting my MATLAB code. However, based on my experiments, it seems that this extension supports code formatting that can either include blanks around the equals sign or not include.This leads to, if I make an oversight, it may lead to inconsistent styles, which is quite uncomfortable for me. I hope to allow users to choose a single formatting style.

dklilley commented 2 months ago

Hi @relifenoxiao , thanks for the request!

Can you provide a bit more detail about the behavior you are requesting, including examples?

Is this functionality that already exists in MATLAB?

relifenoxiao commented 2 months ago

Ooh, thank you for your reply. I'm currently in class, but I will provide additional details and examples regarding my question as soon as possible within a day.

relifenoxiao commented 2 months ago

If there is code that needs to be formatted as follows:

x= 0:0.1:2* pi;
y= sin(x);
z = cos(x);

After using the formatting command based on this extension, there were no changes.
I suspect it's because both indentation styles are valid in MATLAB, but this causes inconsistencies in style.
Although using the extension in the image below can achieve the effect I want (C-style indentation),
268b0e9f9d139981d730862cb399aad9 I'm concerned that this unofficial extension may lead to unknown errors due to lack of maintenance.
Therefore, I hope this extension can allow users to set a unified formatting style.
Or does this feature already exist, and I just haven't found it?

dklilley commented 2 months ago

Thank you for the clarification!

This is functionality which we would like to add in a future release of the extension! We currently do not have this functionality within MATLAB either, but this is a request which we are aware of.

relifenoxiao commented 2 months ago

thanks for your work