Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Parser): FindParentAttributeValue #464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private bool ParseChar()
{
if (NestingLevel - startLevel - 1 < 0)
return null;
var attribRegExpr = new Regex($"\\s(?:{attributeExpr})=\"(?<AttribValue>.*?)\"");
var attribRegExpr = new Regex($"\\s?(?:{attributeExpr})\\s*\\=\\s*\"(?<AttribValue>.*?)\"",RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);
foreach (var start in _containingTagStart.Skip(startLevel))
{
var m = Regex.Match(_data.Span.Slice(start).ToString(), @"^<[^<]+");
Expand Down
6 changes: 6 additions & 0 deletions tests/CompletionEngineTests/AdvancedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public void Binding_Path_Should_Be_Completed_From_xDataType()
AssertSingleCompletion("<UserControl x:DataType=\"Button\"><TextBlock Tag=\"{Binding Path=", "Conte", "Content");
}

[Fact]
public void Binding_Path_Should_Be_Completed_From_xDataType_Issue_463()
{
AssertSingleCompletion("<UserControl x:DataType= \"Button\"><TextBlock Tag=\"{Binding Path=", "Conte", "Content");
}

[Fact]
public void Binding_Path_Should_Be_Completed_From_xDataType2()
{
Expand Down
14 changes: 14 additions & 0 deletions tests/CompletionEngineTests/Parsing/XmlParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,21 @@ public void Should_GetParentTagName_At_Level(string source, int position, int le
Assert.Equal(nestingLevelExpected, state.NestingLevel);
var parentTag = state.GetParentTagName(level);
Assert.Equal(expectedParentTag, parentTag);
}

[Theory]
[InlineData("<UserControl x:DataType=\"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType= \"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType = \"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType =\"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType\t=\r\"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType\t=\n\"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType \t=\r\"Button\"><TextBlock Tag=\"\"")]
[InlineData("<UserControl x:DataType\t =\r\"Button\"><TextBlock Tag=\"\"")]
public void Should_FindParentAttributeValue(string source)
{
var state = XmlParser.Parse(source.AsMemory(),source.Length,0);
Assert.NotNull(state.FindParentAttributeValue("(x\\:)?DataType"));
}

string GetData(string name, [CallerMemberName] string callerMethod = "")
Expand Down