Bug 573636 - Save action "Reduce indentation when possible" breaks text block formatting
Summary: Save action "Reduce indentation when possible" breaks text block formatting
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.19   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-19 07:28 EDT by Alexander Levsha CLA
Modified: 2023-10-17 05:02 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.