Skip to content

Commit

Permalink
Do not suggest repeated attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Jul 31, 2021
1 parent 36bcfff commit 1b32846
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MarkMpn.XmlSchemaAutoComplete/Autocomplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public AutocompleteSuggestion[] GetSuggestions(string text)
}

return suggestions
.Where(a => a.Name.StartsWith(element.CurrentAttribute ?? ""))
.Where(a => a.Name.StartsWith(element.CurrentAttribute ?? "") && !element.Attributes.ContainsKey(a.Name))
.ToArray<AutocompleteSuggestion>();
}
else if (parser.State == ReaderState.InAttributeEquals || parser.State == ReaderState.InAttributeValue)
Expand Down
1 change: 1 addition & 0 deletions MarkMpn.XmlSchemaAutocomplete.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void SuggestsArrayMembers(string input, params string[] elements)
[InlineData("<MyDoc><Members><c ", "xsi:nil", "gender", "surname")]
[InlineData("<MyDoc><Staff ", "xsi:type", "gender", "surname")]
[InlineData("<MyDoc><Staff s", "surname")]
[InlineData("<MyDoc><Staff gender='Male' ", "xsi:type", "surname")]
[InlineData("<MyDoc><Staff f")]
public void SuggestsAttributes(string input, params string[] attributes)
{
Expand Down

0 comments on commit 1b32846

Please sign in to comment.