GNOME Bugzilla – Bug 662956
Wrong indention of blocks (braces and contents) after labels
Last modified: 2020-11-06 20:22:49 UTC
Autoindent do not indent braces and its contents after labels. Example: void helloworld (int english, int japanese) { if (english) { printf ("Hello World!"); } nippon_go: if (japanese) { printf ("Kon'nichiwa Sekai!"); } }
This case is really difficult to catch without a full parser because of the switch() statement: switch(test) { case 1: do_something(); (...) } In this case, you want indentation. In general the style for labels is to put them in the first level, so the whole things would look like that and that should be fine: void helloworld (int english, int japanese) { if (english) { printf ("Hello World!"); } nippon_go: if (japanese) { printf ("Kon'nichiwa Sekai!"); } }
What if it's like this: Check if label is a case in a switch (have "case" before it). Make labels indent like preprocessor directives (always in first level). Is it possible?
Sure it's possible but the indentation code is not entirely easy and it is kind of hard to add more special cases. Also consider the "labels" inside classes (public:, private:, protected:) that would need another special case. Patches of course welcome ;)
I only wanted to add that even inside switch blocks, if's and other blocks have wrong indentation.
bugzilla.gnome.org is being replaced by gitlab.gnome.org. We are closing all old bug reports in Bugzilla which have not seen updates for many years. If you can still reproduce this issue in a currently supported version of GNOME (currently that would be 3.38), then please feel free to report it at https://gitlab.gnome.org/GNOME/anjuta/-/issues/ Thank you for reporting this issue and we are sorry it could not be fixed.