Thanks for your reply Patrick.
Well, I do think that the beautifier (and auto-format) should have every behavior configurable. There are a few things like that which seem not to be configurable.
Here are a few examples (all in C/C++ context):
---------------
This is probably a bug, but in SE 20.x (was not like that in 19.x), if you have auto-surround enabled (that is, if you select some text, like an constant in an if statement, and type an opening parenthesis, it will surround the text with parenthesis), the behavior is different depending on if you selected the text manually, or through a search.
To demonstrate, suppose this code:
...
return (state & SM_ACTIVE ? true : false); /* Better put parenthesis so there's no confusion on precedence rules. */
...
Then, you wish to surround the evaluation with parenthesis. You can select "state & SM_ACTIVE", press opening parenthesis, and it will surround the selection with parenthesis. Moreover, SE, not knowing if your intention is to surround the selection, or overwrite it with something entirely different, keep the selection active. So, if your intention is to replace the text with something different, as in following example:
...
if (link_state & LS_UP) {dome something...}
...
and you wish to replace LS_UP with (LS_ACTIVE | LS_DISABLED). You can highlight LS_UP manually, and type (LS_ACTIVE | LS_DISABLED). The opening parenthesis will auto-surround LS_UP (not what you want), then keeping LS_UP highlighted, as soon as you type LS_ACTIVE..., LS_UP is overwritten. So you end up with the result you wanted (overwriting).
However, above I highlighted LS_UP manually (this is the distinction from the issue bellow). If I do a search for LS_UP. That is, <ctrl-f> LS_UP <enter>. Then you end up with LS_UP highlighted, as above. However, there is an issue if I start replacing the string. As I type the opening parenthesis, LS_UP is auto-surrounded and LS_UP is still highlighted (as above), but here, the cursor is placed on the left of the opening parenthesis. As soon as I continue typing LS_ACTIVE..., the LS_ACTIVE... is inserted on the left of the parenthesis, leaving intact the original string (which is now fully-surrounded).
Example, step by step (with color

)
1st case, with LS_UP highlighted manually, type
(LS_AC...:
if (link_state & |LS_UP) {do something...};if (link_state & (|LS_UP)) {do something...};if (link_state & (L|)) {do something...};if (link_state & (LS|)) {do something...};if (link_state & (LS_|)) {do something...};if (link_state & (LS_A|)) {do something...};if (link_state & (LS_AC|)) {do something...};if (link_state & (LS_ACT|)) {do something...};if (link_state & (LS_ACTI|)) {do something...};...
if (link_state & (LS_ACTIVE | LS_DISABLED|)) {do something...};2nd case, with LS_UP highlighted through the search function:
if (link_state & |LS_UP) {do something...};if (link_state & |(LS_UP)) {do something...};if (link_state & L|(LS_UP)) {do something...};if (link_state & LS|(LS_UP)) {do something...};if (link_state & LS_|(LS_UP)) {do something...};if (link_state & LS_A|(LS_UP)) {do something...};if (link_state & LS_AC|(LS_UP)) {do something...};if (link_state & LS_ACT|(LS_UP)) {do something...};if (link_state & LS_ACTI|(LS_UP)) {do something...};...
if (link_state & LS_ACTIVE | LS_DISABLED|(LS_UP)) {do something...};---------------
Another case, if you enable the formatting option
Spacing-->Statements-->General Statement-->Space after semicolumn, and set it to
ON, this will make sure that spaces are inserted after the semicolumn. For example:
Disabled:
a = 1;b = 2;c = 3;Enabled:
a = 1; b = 2; c = 3;If you beautify the code, it will add spaces after every semi-column, even at end of line. If the semi-column is the last character at end of line (or end of file), then the beautifier should probably not insert a space after this last semi-column. I have checked and the behavior is correct if the character following the semi-column is a space or a tab.
---------------
It would be nice to have an option to left-align local pointer variables declaration with the asterisk sticking out on the left, or to not separate the assignment from the variable name. For example, there is an option
Spacing-->Declarations-->Local Var Declarations-->Name Justification, that let you align the names:
Without:
void func(void)
{
int a;
bool b = true;
char *pointer;
char **str_array;
short some_very_long_variable_name;
...
}
With:
void func(void)
{
int a;
bool b = true;
char *pointer;
char **str_array;
short some_very_long_variable_name;
...
}
It would be nice to left-align with the pointer asterisk sticking out and/or with preserving spacing between variable name and assignment. For ex:
void func(void)
{
int a;
bool b = true;
char *pointer;
char **str_array;
short some_very_long_variable_name;
...
}
---------------
Following the last feature, it would be nice to have this for function parameters too. Maybe in 2 different option groups (newlines and spacing). To have a way to always put each function parameters on different lines, and to have the above spacing rules apply to the parameters. So to force to always have something like:
int func(int a,
const char *msg,
char *ret_str,
int flags = FLAGS_NONE);
I know this is a lot! But those would be nice-to-have features

Thanks,
Eric