Skip to content

Commit

Permalink
Comments throws off diagnostic (cvc-complex-type.2.3) mark onto the
Browse files Browse the repository at this point in the history
wrong location

Fixes #1495

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
azerr authored and datho7561 committed Mar 1, 2023
1 parent 0436a41 commit fe8beb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -684,7 +684,7 @@ public static Range selectFirstNonWhitespaceText(int offset, DOMDocument documen
DOMNode element = document.findNodeAt(offset);
if (element != null) {
for (DOMNode node : element.getChildren()) {
if (node.isCharacterData()) {
if (node.isText() || node.isCDATA()) {
DOMCharacterData data = (DOMCharacterData) node;
int start = data.getStartContent();
Integer end = null;
Expand Down
Expand Up @@ -1149,6 +1149,23 @@ public void cvc_complex_type_2_3_elementBeforeText() throws BadLocationException
XMLAssert.testCodeActionsFor(xml, diagnostic, ca(diagnostic, te(3, 10, 3, 21, "")));
}

@Test
public void cvc_complex_type_2_3_textAfterComment() throws BadLocationException {
// See https://github.com/eclipse/lemminx/issues/1495
String xml = "<?xml version='1.0' encoding='utf-8'?>\r\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n"
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"
+ " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\r\n"
+ " <modelVersion>4.0.0</modelVersion>\r\n"
+ " <!-- Comment -->\r\n"
+ " abcd efgh\r\n"
+ " \r\n"
+ "</project>";
Diagnostic diagnostic = d(6, 4, 8, XMLSchemaErrorCode.cvc_complex_type_2_3);
testDiagnosticsWithCatalogFor(xml, diagnostic);
XMLAssert.testCodeActionsFor(xml, diagnostic, ca(diagnostic, te(6, 4, 6, 8, "")));
}

@Test
public void diagnosticRelatedInformationWithXMLModelSchemaProblem() throws Exception {
ContentModelSettings settings = new ContentModelSettings();
Expand Down

0 comments on commit fe8beb4

Please sign in to comment.