Skip to content

Commit

Permalink
Merge pull request #464 from workgroupengineering/fixes/Intellisense/…
Browse files Browse the repository at this point in the history
…Issue_463

fix(Parser): FindParentAttributeValue
  • Loading branch information
maxkatz6 authored Mar 28, 2024
2 parents 377ce6e + 6bd00df commit 08aa4ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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

0 comments on commit 08aa4ea

Please sign in to comment.