From 2fb24b543841c49ab222d2b522383b1bfe6486b5 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Thu, 19 Feb 2015 14:46:21 +0300 Subject: [PATCH] Removed a strange logic which breaks alignment if there is an extra line break between blocks to be aligned. --- .../com/intellij/formatting/AlignmentImpl.java | 16 +--------------- xml/tests/testData/mover/tag8_afterDown.xml | 2 +- xml/tests/testData/mover/tag8_afterUp.xml | 4 ++-- xml/tests/testData/mover/tag9_afterDown.xml | 4 ++-- xml/tests/testData/mover/tag9_afterUp.xml | 6 +++--- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java b/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java index fc3ba2ce0691..ab60d0dcfddf 100644 --- a/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java @@ -107,33 +107,19 @@ class AlignmentImpl extends Alignment { } LeafBlockWrapper result = null; if (myOffsetRespBlocks != EMPTY) { - LeafBlockWrapper firstBlockAfterLineFeed = null; LeafBlockWrapper firstAlignedBlock = null; LeafBlockWrapper lastAlignedBlock = null; for (final LeafBlockWrapper current : myOffsetRespBlocks) { if (block == null || current.getStartOffset() < block.getStartOffset()) { - if (!onDifferentLines(current, block)) { - continue; - } if (firstAlignedBlock == null || firstAlignedBlock.getStartOffset() > current.getStartOffset()) { firstAlignedBlock = current; } - if (lastAlignedBlock == null || lastAlignedBlock.getStartOffset() < current.getStartOffset()) { lastAlignedBlock = current; } - - if (firstBlockAfterLineFeed == null && current.getWhiteSpace().containsLineFeeds()) { - firstBlockAfterLineFeed = current; - } - } - //each.remove(); } - if (firstBlockAfterLineFeed != null) { - result = firstBlockAfterLineFeed; - } - else if (firstAlignedBlock != null) { + if (firstAlignedBlock != null) { result = firstAlignedBlock; } else { diff --git a/xml/tests/testData/mover/tag8_afterDown.xml b/xml/tests/testData/mover/tag8_afterDown.xml index d5ba11297737..d41cff11ddae 100644 --- a/xml/tests/testData/mover/tag8_afterDown.xml +++ b/xml/tests/testData/mover/tag8_afterDown.xml @@ -12,5 +12,5 @@ xsi:schemaLocation= http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd" -xmlns:async="http://jboss.com/products/seam/async" + xmlns:async="http://jboss.com/products/seam/async" /> \ No newline at end of file diff --git a/xml/tests/testData/mover/tag8_afterUp.xml b/xml/tests/testData/mover/tag8_afterUp.xml index 69f05250864f..72478c4e008a 100644 --- a/xml/tests/testData/mover/tag8_afterUp.xml +++ b/xml/tests/testData/mover/tag8_afterUp.xml @@ -4,8 +4,8 @@ xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:framework="http://jboss.com/products/seam/framework" xmlns:web="http://jboss.com/products/seam/web" xmlns:security="http://jboss.com/products/seam/security" -xmlns:async="http://jboss.com/products/seam/async" -xmlns:xsi + xmlns:async="http://jboss.com/products/seam/async" + xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd diff --git a/xml/tests/testData/mover/tag9_afterDown.xml b/xml/tests/testData/mover/tag9_afterDown.xml index 706403205e66..a089be0e1508 100644 --- a/xml/tests/testData/mover/tag9_afterDown.xml +++ b/xml/tests/testData/mover/tag9_afterDown.xml @@ -6,8 +6,8 @@ xmlns:web="http://jboss.com/products/seam/web" xmlns:security="http://jboss.com/products/seam/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:async="http://jboss.com/products/seam/async" -xsi:schemaLocation= - "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd + xsi:schemaLocation= + "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd diff --git a/xml/tests/testData/mover/tag9_afterUp.xml b/xml/tests/testData/mover/tag9_afterUp.xml index 0cca26139769..656225743cf1 100644 --- a/xml/tests/testData/mover/tag9_afterUp.xml +++ b/xml/tests/testData/mover/tag9_afterUp.xml @@ -4,12 +4,12 @@ xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:framework="http://jboss.com/products/seam/framework" xmlns:web="http://jboss.com/products/seam/web" xmlns:security="http://jboss.com/products/seam/security" -xsi:schemaLocation= - "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd + xsi:schemaLocation= + "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd" -xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:async="http://jboss.com/products/seam/async" /> \ No newline at end of file