diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs
index 407ae7feef..19d70bd547 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlParser.cs
@@ -243,12 +243,15 @@ namespace ICSharpCode.XmlEditor
}
// Find equals sign.
+ bool foundQuoteChar = false;
for (int i = index; i > elementStartIndex; --i) {
char ch = xml[i];
- if (ch == '=') {
+ if (ch == '=' && foundQuoteChar) {
index = i;
ignoreEqualsSign = true;
break;
+ } else if (IsQuoteChar(ch)) {
+ foundQuoteChar = true;
}
}
} else {
@@ -364,11 +367,14 @@ namespace ICSharpCode.XmlEditor
// Find equals sign.
int equalsSignIndex = -1;
+ bool foundQuoteChar = false;
for (int i = index; i > elementStartIndex; --i) {
char ch = xml[i];
- if (ch == '=') {
+ if (ch == '=' && foundQuoteChar) {
equalsSignIndex = i;
break;
+ } else if (IsQuoteChar(ch)) {
+ foundQuoteChar = true;
}
}
@@ -378,12 +384,12 @@ namespace ICSharpCode.XmlEditor
// Find attribute value.
char quoteChar = ' ';
- bool foundQuoteChar = false;
+ foundQuoteChar = false;
StringBuilder attributeValue = new StringBuilder();
for (int i = equalsSignIndex; i < xml.Length; ++i) {
char ch = xml[i];
if (!foundQuoteChar) {
- if (ch == '\"' || ch == '\'') {
+ if (IsQuoteChar(ch)) {
quoteChar = ch;
foundQuoteChar = true;
}
@@ -391,7 +397,7 @@ namespace ICSharpCode.XmlEditor
if (ch == quoteChar) {
// End of attribute value.
return attributeValue.ToString();
- } else if (IsAttributeValueChar(ch) || (ch == '\"' || ch == '\'')) {
+ } else if (IsAttributeValueChar(ch) || IsQuoteChar(ch)) {
attributeValue.Append(ch);
} else {
// Invalid character found.
@@ -783,5 +789,10 @@ namespace ICSharpCode.XmlEditor
}
return new XmlElementPath();
}
+
+ static bool IsQuoteChar(char ch)
+ {
+ return (ch == '\"') || (ch == '\'');
+ }
}
}
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Parser/AttributeValueUnderCursorTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Parser/AttributeValueUnderCursorTests.cs
index bbbddb9ac9..828618e238 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Parser/AttributeValueUnderCursorTests.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Parser/AttributeValueUnderCursorTests.cs
@@ -85,6 +85,8 @@ namespace XmlEditor.Tests.Parser
string xaml = "";
int offset = "