Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344459 - Indentation incorrect if formatting selection in XML file and first line is not selected completely
Summary: Indentation incorrect if formatting selection in XML file and first line is n...
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows Vista
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: wst.xml CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-02 10:17 EDT by Tobias Oberlies CLA
Modified: 2013-06-19 11:14 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Oberlies CLA 2011-05-02 10:17:19 EDT
When I select a part of an XML file, and the selection starts directly at the first selected element (i.e. it does not include any whitespace before the first element), hitting CTRL+SHIFT+F formats the selection with an incorrect indentation.

Steps to reproduce:
1) Create a simple XML file with at least three levels of nesting, e.g.

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<selected>
		<inner></inner>
			<inner></inner>
	</selected>
</root>

2) Select an element below the root element completely, e.g. by placing the cursor inside the element and pressing SHIFT+ALT+UP-ARROW one or more times. In the example, the following shall be selected (and ^ and $ mark beginning and end of the selection):

<?xml version="1.0" encoding="UTF-8"?>
<root>
	^<selected>
		<inner></inner>
			<inner></inner>
	</selected>$
</root>

3) Format the selection (CTRL+SHIFT+F). From the second line, the indentation is incorrect:

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<selected>
	<inner></inner>
	<inner></inner>
</selected>
</root>

The result should be the same as if the whole file was formatted, i.e.

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<selected>
		<inner></inner>
		<inner></inner>
	</selected>
</root>
Comment 1 Stanislav Marencik CLA 2013-04-12 09:54:51 EDT
In my case the selected has result indent always one tab (4 spaces in my case)
    <dependencies>
        ^<dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>$

ctrl+shift+F
An the result is:
    <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>