autoformat strange indets

In case of nested control structures the behavior really looks strange.
The sketch was auto-formatted (IDE 1.8.5).

void setup() {
  // of course this code does not
  // make any sense but compiles fine

  // strange auto format behavior:

  // (1) normal:
  while (boo1()) voo1();

  // (2) still normal as expected:
  while (boo1()) if (boo2()) voo1();
    else voo2();

  // (3) same as (2) but surprising:
    while (boo1()) if (boo2()) voo1(); else voo2();

  // (5)  as expected:
  while (boo1()) while (boo2()) voo1();

  // (6)  surprising:
    while (boo1()) do voo1(); while (boo2());


void loop() {
  // put your main code here, to run repeatedly:


boolean boo1() {}
boolean boo2() {}
void voo1() {}
void voo2() {}

The indents are not as they should be.
Shouldn’t it be fixed some time?

The IDE uses the astyle C formatting program. It is documented here. You can set your own preferences for this program in a file called formatter.conf. The original version of the file is in your arduino installation's .../lib directory. Once you've modified it the way you like, write your version into the same directory as your preferences.txt (look right at the bottom of the File|Preferences dialog for the pathname to this file).
This is my current version of the formatter.conf file:

# This configuration file contains a selection of the available options provided by the formatting tool "Artistic Style"
# If you wish to change them, don't edit this file.
# Instead, copy it in the same folder of file "preferences.txt" and modify the copy. This way, you won't lose your custom formatter settings when upgrading the IDE
# If you don't know where file preferences.txt is stored, open the IDE, File -> Preferences and you'll find a link

# I added this

# This is standard Arduino IDE
# 2 spaces indentation

# also indent macros

# indent classes, switches (and cases), comments starting at column 1

# put a space around operators
# I would have kept this except that it also pads
# this: f(1,'c') to this f(1, 'c')

# put a space after if/for/while

# if you like one-liners, keep them


I don't know if there are options in astyle to modify the behaviour of what you have shown but dig through the docs and you might be able to fix it up to work the way you like.