Bug 573636

Summary: Save action "Reduce indentation when possible" breaks text block formatting
Product: [Eclipse Project] JDT Reporter: Alexander Levsha <levsha.alexander>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: jonah, patrick.warnecke
Version: 4.19   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Alexander Levsha CLA 2021-05-19 07:28:09 EDT
I have an XML or whatever new Java Text block:
    static String s = """
            <db_info>
                <name>empty</name>
            </db_info>""";

When Save action "Code Style - Reduce indentation when possible" is enabled saving the file breaks the Text block content:

    static String s = """
            <db_info>
    <name>empty</name>
    </db_info>""";

Here's my full Save actions list:

Convert control statement bodies to block
Convert 'for' loops to enhanced 'for' loops
Add final modifier to private fields
Simplify lambda expression and method reference syntax
Convert fields into local variables if the use is only local
Make inner classes static where possible
Remove unused imports
Add missing '@Override' annotations
Add missing '@Override' annotations to implementations of interface methods
Add missing '@Deprecated' annotations
Remove unnecessary casts
Remove unnecessary '$NON-NLS$' tags
Remove trailing white spaces on all lines
Correct indentation
Use diamond operator
Comment 1 Patrick Warnecke CLA 2021-11-26 08:02:52 EST
I'm running into the same problem, though I think it is not related to the "Reduce indentation when possible" but rather "Correct indentation". My expectation would be that eclipse doesn't change the text blocks at all, with either of the flags.