Bug 505187 - Nested switchs don't behave correctly
Summary: Nested switchs don't behave correctly
Status: RESOLVED DUPLICATE of bug 352167
Alias: None
Product: kdevelop
Classification: Applications
Component: Astyle (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-03 23:08 UTC by Miguel Angel Lopez
Modified: 2025-06-04 08:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Angel Lopez 2025-06-03 23:08:24 UTC
SUMMARY
When inside a case in a switch there's another switch the alignment doesn't goes back to where it should go

STEPS TO REPRODUCE
1.  Create a switch-case.
2.  Inside a case create another switch-case.
3.  Add a case after the end of the nested switch-case.

OBSERVED RESULT
The indentation doesn't takes into account that the inner switch-case has ended and the next outer case uses the inner case indent.

switch (a)
{
    case 0:
        break;
    case 1:
        break;
    case 2:
        switch(b)
        {
            case 0:
                break;
            case 1:
                break;
        }
        break;
            case 3:
                break;
}

EXPECTED RESULT
The outer case after closing the inner switch-case should be at the same indentation level as the case before the nested switch-case.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Raspberry Pi OS Bookworm
KDE Plasma Version: 5.27.5-2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
Comment 1 Igor Kushnir 2025-06-04 08:07:04 UTC
I suppose your complaint is about the formatting as you type. This behavior is governed by the KTextEditor framework. I can reproduce this issue in KDevelop version 6.2 and Kate version 25.04.

KDevelop allows to configure your preferred formatting style for each language on the Source Formatter page of the Configure KDevelop dialog. Then you can trigger reformatting by selecting some code and triggering the Reformat Source action (or not selecting anything to reformat the entire document). A custom shortcut can be assigned to this action. Be sure to back up your code, e.g. by committing first, before trying unfamiliar IDE features.
Comment 2 Igor Kushnir 2025-06-04 08:20:11 UTC

*** This bug has been marked as a duplicate of bug 352167 ***