switch, adding new case formatting is tabbed

When I add the second case I don't type backspace to set the tab to the correct tab I thought that clion would automatically tab it so I left it like that and came here to tell you that clion isn't automatically indenting switch case to align all cases automatically. I'm using the commodore theme otherwise everything else is default:

 

#include <iostream>

using namespace std;

enum PlayerStatus {
    PS_Running,
    PS_Walking,
    PS_Crouching
};

const float RunSpeed = 800.f;
const float WalkSpeed = 500.f;
const float CrouchSpeed = 350.f;

void UpdateMovementSpeed(PlayerStatus P_Status, float& speed);

int main() {

    float MovementSpeed;

    PlayerStatus status = PS_Crouching;

    UpdateMovementSpeed(status, MovementSpeed);

    cout << "Movement speed: " << MovementSpeed << endl;

    system("pause");
}

void UpdateMovementSpeed(PlayerStatus P_Status, float& speed) {
    switch (P_Status) {
        case PS_Running:
            speed = RunSpeed;
            break;
            case PS_Walking:
            speed = WalkSpeed;
            break;
            case PS_Crouching:
            speed = CrouchSpeed;
    }
}

 

 

1
5 comments

Hello!

So far, I can't reproduce the issue in a default "Hello, World!" project (File | New Project > C++ Executable > Create). As soon as I type : after the second case, the line gets indented correctly.

Does the issue happen for you in the default "Hello, World!" project (File | New Project > C++ Executable > Create)?

0

I made a second project and copied the code to include the main and above code and then typed out the bottom function and it does not indent switch case for me so I took a video of if and will show you now on youtube:

 

https://youtu.be/2TXPP1S7qj4

0

any solutions? this is happening in clion and rider. 

 

0

Nandanramesh13, for me, case gets indented as soon as I type a colon:

Does it work differently for you?

0

Hello Anna Falevskaya, case does gets indented as soon as I type a colon, but 90% of the time I use code complete, so when I press Tab, it gets auto completed along with colon, so no indentation. So I have to manually back indent each time i use code complete. 

0

Please sign in to leave a comment.