From 9234b37b1a81a467a26eb2b999a2681339d37f7c Mon Sep 17 00:00:00 2001 From: azerr Date: Wed, 15 Feb 2023 16:00:11 +0100 Subject: [PATCH] XML attribute associated to wrong type from XSD Fixes https://github.com/redhat-developer/vscode-xml/issues/524 Signed-off-by: azerr --- .../lemminx/utils/XMLPositionUtility.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/XMLPositionUtility.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/XMLPositionUtility.java index d45f292cc..5f513706b 100644 --- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/XMLPositionUtility.java +++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/XMLPositionUtility.java @@ -141,8 +141,9 @@ public static Range selectAttributeValueFromGivenValue(String attrValue, int off DOMNode element = document.findNodeAt(offset); if (element != null && element.hasAttributes()) { List attribues = element.getAttributeNodes(); - for (DOMAttr attr : attribues) { - if (attrValue.equals(attr.getValue())) { + for (int i = attribues.size() - 1; i >= 0; i--) { + DOMAttr attr = attribues.get(i); + if (offset > attr.getStart() && attrValue.equals(attr.getValue())) { return createAttrValueRange(attr, document); } } @@ -1151,17 +1152,17 @@ public static Position getMatchingTagPosition(DOMDocument xmlDocument, Position /** * Select the value from the start/end node without quote. - * + * * For the given attr value: - * + * *

* *

- * + * * it will return range without ". - * + * * @param node the DOM node. - * + * * @return the value from the start/end node without quote. */ public static Range selectValueWithoutQuote(DOMRange node) { @@ -1169,4 +1170,4 @@ public static Range selectValueWithoutQuote(DOMRange node) { return createRange(node.getStart() + 1, node.getEnd() - 1, document); } -} \ No newline at end of file +}