diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/StringUtils.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/StringUtils.java index 5323e7aee8..6f5f12a981 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/StringUtils.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/StringUtils.java @@ -39,14 +39,18 @@ public static boolean isEmpty(String value) { * @return the result of normalize space of the given string. */ public static void normalizeSpace(String str, StringBuilder b) { + String space = ""; for (int i = 0; i < str.length(); ++i) { char c = str.charAt(i); if (Character.isWhitespace(c)) { if (i <= 0 || Character.isWhitespace(str.charAt(i - 1))) continue; - b.append(' '); + //b.append(' '); + space = " "; continue; } + b.append(space); + space = ""; b.append(c); } } diff --git a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/XMLBuilder.java b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/XMLBuilder.java index dcfa5ad7fe..e2c9adbc2e 100644 --- a/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/XMLBuilder.java +++ b/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/utils/XMLBuilder.java @@ -203,6 +203,7 @@ public XMLBuilder addContentComment(String content) { if (isJoinCommentLines()) { xml.append(" "); xml.append(normalizeSpace(content)); + xml.append(" "); } else { xml.append(content); } diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaHoverExtensionsTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaHoverExtensionsTest.java index 35f63f36a6..7c171161af 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaHoverExtensionsTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaHoverExtensionsTest.java @@ -28,7 +28,7 @@ public void testTagHover() throws BadLocationException { "\r\n" + " "; assertHover(xml, - "Defines a single (usually named) bean. A bean definition may contain nested tags for constructor arguments, property values, lookup methods, and replaced methods. Mixing constructor injection and setter injection on the same bean is explicitly supported. ", + "Defines a single (usually named) bean. A bean definition may contain nested tags for constructor arguments, property values, lookup methods, and replaced methods. Mixing constructor injection and setter injection on the same bean is explicitly supported.", 2); }; @@ -39,7 +39,7 @@ public void testAttributeNameHover() throws BadLocationException { "\r\n" + " "; assertHover(xml, - "The fully qualified name of the bean's class, except if it serves only as a parent definition for child bean definitions. ", + "The fully qualified name of the bean's class, except if it serves only as a parent definition for child bean definitions.", null); }; diff --git a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFormatterTest.java b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFormatterTest.java index ac9ee1b411..f8160475c6 100644 --- a/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFormatterTest.java +++ b/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/services/XMLFormatterTest.java @@ -287,7 +287,7 @@ public void testJoinCDATALines() throws BadLocationException { "line 2" + lineSeparator() + "line 3" + lineSeparator() + "]]> "; - String expected = "" + lineSeparator() + " " + lineSeparator() + ""; + String expected = "" + lineSeparator() + " " + lineSeparator() + ""; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); formattingOptions.setJoinCDATALines(true); format(content, expected, formattingOptions); @@ -353,7 +353,7 @@ public void testCommentFormatSameLine() throws BadLocationException { " Content" + lineSeparator() + " "; String expected = - "Content " + lineSeparator() + + "Content " + lineSeparator() + ""; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); @@ -397,7 +397,7 @@ public void testElementContentNormalized() throws BadLocationException { " Content5" + lineSeparator() + ""; String expected = - "Content Content2 Content3 Content4 Content5 "; + "Content Content2 Content3 Content4 Content5"; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); @@ -515,8 +515,8 @@ public void testContentFormatting1() throws BadLocationException { " " + lineSeparator() + ""; String expected = - "Content " + lineSeparator() + - " Content2 Content3 " + lineSeparator() + + "Content" + lineSeparator() + + " Content2 Content3" + lineSeparator() + ""; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); @@ -587,7 +587,7 @@ public void testContentFormatting4() throws BadLocationException { String content = " content "; String expected = - "content "; + "content"; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); formattingOptions.setJoinContentLines(true); @@ -601,7 +601,7 @@ public void testContentFormatting5() throws BadLocationException { " Content" + lineSeparator() + ""; String expected = - "Content "; + "Content"; XMLFormattingOptions formattingOptions = createDefaultFormattingOptions(); formattingOptions.setJoinContentLines(true);